comma operator causes hard to spot bugs
Era Scarecrow
rtcvb32 at yahoo.com
Fri Apr 27 21:04:09 PDT 2012
On Saturday, 28 April 2012 at 03:19:19 UTC, Era Scarecrow wrote:
> becomes:
>
> int c = {a = b; b = 7; 8;};
> int c = {a = b; b = 7; return 8;};
>
> Like this it looks less like a function call and a scope
> instead; but still returns something from a scope as it's
> return value. Although then it's almost a lambda function,
> except without calling parameters. Mmm thoughts?
I tend to edit my text all over the place so sorry.
The first one {a = b; b = 7; 8;}; was suppose to have a note it
would error while assigning value of void return value.
Using the blocks/scope makes the book example look less like a
function call; But can still return something from a scope as
it's return value. Although then it's almost a lambda function
except without calling parameters.
Most likely it wouldn't return anything, if you needed a return
you use a lambda instead. So:
a = b; b = 7;
int c = 8; //returns void so there is simply no block
or
int c = (){a = b; b = 7; return 8;};
More information about the Digitalmars-d
mailing list