The Comma Operator's Deprecation Can't Come Soon Enough
Ali Çehreli via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jul 23 13:00:19 PDT 2014
On 07/23/2014 12:04 PM, Ali Çehreli wrote:
> On 07/23/2014 10:59 AM, sigod wrote:
>> On Wednesday, 23 July 2014 at 17:25:43 UTC, Yota wrote:
>>> It appears Microsoft is musing the idea of adding this operator to C#
>>> and VB.Net. Only instead of it being a comma, they're going with a
>>> semicolon.
>>> https://roslyn.codeplex.com/wikipage?title=Language%20Feature%20Status&referringTitle=Documentation
>>>
>>>
>>>
>>> I dislike the comma operator as well, but would there be any problems
>>> if it were a semicolon instead? I think the new symbol would fit well
>>> in for() loops.
>>
>> `(var x = Foo(); Write(x); x * x)`
>>
>> Looks kinda strange.
>
> Reminds me... Is everybody aware of D's for syntax?
>
> import std.stdio;
>
> void main()
> {
> for ( {
> int i = 42;
> double d = 1.5;
> string s = "hello";
> } i < 100; i *= 2) {
>
> writefln("In the loop with %s %s %s", i, d, s);
> }
> }
>
> :)
>
> Also note the absence of ; before the loop condition.
>
> Ali
>
And totally legal:
http://dlang.org/statement.html#ForStatement
ForStatement:
for ( Initialize Testopt ; Incrementopt ) ScopeStatement
Initialize:
;
NoScopeNonEmptyStatement <-- THIS
NoScopeNonEmptyStatement:
NonEmptyStatement
BlockStatement <-- THIS
BlockStatement:
{ }
{ StatementList } <-- THIS
Ali
More information about the Digitalmars-d
mailing list