Rant after trying Rust a bit

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 23 13:09:33 PDT 2015


On 7/23/2015 7:49 AM, ixid wrote:
> If we had a clean sheet wouldn't it be better to have if return a value and
> ditch ternary?

Then we'd start seeing code like:

     x = 45 + if (y == 10) { while (i--) z += call(i); z; } else { switch (x) { 
case 6: foo(); y; } + tan(z);

I.e. the embedding of arbitrary statements within expressions. We already have 
some of this with embedded anonymous lambda support, and I've discovered one 
needs to be very careful in formatting it to not wind up with an awful 
unreadable mess.

So I'd be really reluctant to continue down that path.

Now, if you want to disallow { } within the embedded if statement, then the 
proposal becomes nothing more than:

     ? => if
     : => else

which is a potayto potahto thing.

I agree that trivial syntax issues actually do matter, but having used ?: a lot, 
I have a hard time seeing embeddable if-else as a real improvement, in fact I 
find it more than a little jarring to see.


More information about the Digitalmars-d mailing list