July 23, 2014 Re: The Comma Operator's Deprecation Can't Come Soon Enough | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yota | 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.
|
July 23, 2014 Re: The Comma Operator's Deprecation Can't Come Soon Enough | ||||
---|---|---|---|---|
| ||||
Posted in reply to sigod | 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
|
July 23, 2014 Re: The Comma Operator's Deprecation Can't Come Soon Enough | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Wed, Jul 23, 2014 at 12:04:52PM -0700, Ali Çehreli via Digitalmars-d wrote: [...] > 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. [...] :-O Arghhhh... my eyes are bleeding from this nasty syntax... :-( T -- This sentence is false. |
July 23, 2014 Re: The Comma Operator's Deprecation Can't Come Soon Enough | ||||
---|---|---|---|---|
| ||||
Posted in reply to sigod | On Wednesday, 23 July 2014 at 17:59:42 UTC, 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.
Fairly consistent with functional languages like F#, however.
(let x = Foo() in (Write x; x * x))
|
July 23, 2014 Re: The Comma Operator's Deprecation Can't Come Soon Enough | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Wednesday, 23 July 2014 at 19:04:52 UTC, Ali Çehreli wrote:
> 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
What in the hell is this? Is the { int i = 42; ... } block counted as a lambda or a scope? In that case, why is i still available outside the block in the `i < 100; i *= 2` expressions? I feel like my whole world has been turned upside down.
|
July 23, 2014 Re: The Comma Operator's Deprecation Can't Come Soon Enough | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | 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 |
Copyright © 1999-2021 by the D Language Foundation