[Haskell-cafe] Functions are first class values in C
Cristian Baboi
cristian.baboi at gmail.com
Sat Dec 22 09:15:18 EST 2007
On Sat, 22 Dec 2007 14:55:44 +0200, Peter Verswyvelen <bf3 at telenet.be>
wrote:
> Before I knew Haskell, the OO community started to embrace the concept
> of "interfaces" more and more (aka purely abstract classes). Furthermore
> in OO, many bugs are caused IMO by keeping track of mutable state and
> caches (which is often premature optimization). So for complicated
> tasks, I tended to use more and more immutable objects, e.g. objects
> that could be constructed once, but not mutated. And then I noticed that
> it was often not needed to precompute all the values that got passed to
> the constructor, so I added C# "properties" that computed the inner
> cached values once, lazily.
Lazy constant in C:
int C1 (){
return 7;
}
C1 is computed only when you apply the operator () to it.
> IMO Haskell embraces the above ideas and much more, with the difference
> it encapsulates these ideas nicely and concisely, so you need only a
> fraction of the lines of code :)
This is why we have syntactic sugar :)
More information about the Haskell-Cafe
mailing list