Sun, 07 Mar 2010 14:52:09 -0800, Walter Bright wrote: > retard wrote: >> It's perfectly clear to me that no matter what you do, D won't become a >> functional language because the core runs on an imperative Turing >> machine. But the functional constructs can help building more readable >> and reliable code. That's why C# and Scala got those features.. > > I'll reply to your other points later, but this one bothers me. Neither > C# nor Scala support pure functions or immutable data structures, which > are fundamental to FP. I don't see how they can be considered as > supporting functional programming. > > http://en.wikipedia.org/wiki/Scala_(programming_language) #Functional_programming > > http://www.25hoursaday.com/weblog/CommentView.aspx? guid=3D5755BF-43CF-4D47-A7EC-B60F6B536702
Agreed, D 2 is rather unique among imperative languages. I guess no other imperative language provides such a transitive const system. The lack of strong const types sometimes bites you. On the other hand Scala does provide a shallow form of immutability and some immutable data structures in the standard library. I don't know if D2 provides any built-in immutable data structures. I guess just wrapping a data structure in immutable() won't suffice since there are probably some state changing functions in the mutable implementation that need to copy when dealing with immutable values. The good thing in Scala and C# is that they both provide nice tools for expressing functional problems without too much verbosity. When the const system in D works, I guess it solves the other part of the problem. Too bad you can't have them all without resorting to pure functional languages. In the functional language community they have been spending much time on the opposite, to find ways to add mutability into referentially transparent programs. Some examples: http://www.haskell.org/haskellwiki/DDC http://cs.anu.edu.au/~Ben.Lippmeier/project/thesis/thesis-lippmeier- sub.pdf https://www.cs.tcd.ie/Edsko.de.Vries/pub/ MakingUniquenessTypingLessUnique.pdf
