Damn C++ and damn D!

so so at so.so
Sun Feb 5 07:24:56 PST 2012


On Sunday, 5 February 2012 at 15:17:39 UTC, Jose Armando Garcia 
wrote:

> What I would really like to see in D is:
>
> immutable variable = if (boolean condition)
> {
> // initialize based on boolean condition being true
> }
> else
> {
> // initialize based on boolean condition being false
> }
>
> Scala has this and find it indispensable for functional and/or
> immutable programming. Yes, I have been programming with Scala 
> a lot
> lately. It has a lot of problem but it has some really cool 
> constructs
> like the one above. Scala also has pattern matching and 
> structural
> typing but that may be asking too much ;).
>
> I am not sure what it would take to implement this in D but I am
> thinking we need the concept of a void type (Unit in scala). 
> Thoughts?

What am i missing?
I can't see the difference between that and "static if".

static if (boolean condition)
{
  // initialize based on boolean condition being true
  immutable variable = ...
}
else
{
  // initialize based on boolean condition being false
  immutable variable = ...
}



More information about the Digitalmars-d mailing list