Rant after trying Rust a bit
ixid via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 24 03:06:57 PDT 2015
On Thursday, 23 July 2015 at 20:09:34 UTC, Walter Bright wrote:
> 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.
As opposed to:
auto n = {
if (y == 10) {
return {
while (i--)
z += call(i);
return z;
}();
} else {
return {
switch (x) {
case 6: return foo();
default: return y;
}
}();
}
}() + tan(z);
You can already do that, it's even uglier.
More information about the Digitalmars-d
mailing list