Trip notes from Israel
Andrei Alexandrescu via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Mon May 22 08:30:03 PDT 2017
On 05/22/2017 11:26 AM, Andrei Alexandrescu wrote:
> On 05/22/2017 11:23 AM, Adam D. Ruppe wrote:
>> On Monday, 22 May 2017 at 15:05:24 UTC, Andrei Alexandrescu wrote:
>>> mixin is a statement so it needs a terminator, hence
>>> the semicolon at the very end. In turn, mixin takes
>>> a string (the concatenation of variable op
>>
>> That actually depends on context! The mixin statement needs
>> statements, but the mixin expression takes expressions. Same mixin
>> keyword, but if it is in the context of a statement it is a statement
>> and in the context of an expression, it is an expression.
>>
>> ---
>> void main() {
>> int payload;
>> mixin("++payload;"); // statement, ; required
>> int b = mixin("++payload"); // expression, ; would be wrong there
>> and cause an error!
>> }
>> ---
>>
>> http://dlang.org/spec/expression.html#MixinExpression
>> http://dlang.org/spec/statement.html#MixinStatement
>
> Yah, didn't want to overload the article (or the discussion) with the
> expression/statement distinction. -- Andrei
Updated the post, it's an interesting point after all. Thanks! -- Andrei
More information about the Digitalmars-d-announce
mailing list