April 28, 2016
Dne 28.4.2016 v 22:20 Steven Schveighoffer via Digitalmars-d napsal(a):

> (BTW, swift doesn't allow arbitrary new scopes)
And D does?

April 28, 2016
On 4/28/16 4:36 PM, Daniel Kozak via Digitalmars-d wrote:
> Dne 28.4.2016 v 22:20 Steven Schveighoffer via Digitalmars-d napsal(a):
>
>> (BTW, swift doesn't allow arbitrary new scopes)
> And D does?
>

Sure.

{
   int i = 0;
   while(i < 100) {...}
}

// i no longer defined

Won't work in swift.

-Steve
April 28, 2016
Wierd, I am almost sure it does not work for me last time when I tried :)


Dne 28.4.2016 v 22:54 Steven Schveighoffer via Digitalmars-d napsal(a):
> {
>    int i = 0;
>    while(i < 100) {...}
> }

April 28, 2016
On Thu, Apr 28, 2016 at 08:01:02PM +0000, Seb via Digitalmars-d wrote:
> On Thursday, 28 April 2016 at 18:53:21 UTC, Steven Schveighoffer wrote:
> >grrr... and they removed C-style for statements (i.e. for(;;))
> >
> >-Steve
> 
> I agree with the other people on this list - cleaning up a language is
> great and should be done.
> `++` might be a bad example, but (empty) C-style for loops are!

I find for(;;) far more logical than other vacuous workarounds like
while(1) or while(true). All you have to do is to blur your eyes and
pretend the (;;) looks like an infinity symbol, and you can read it as
"for-ever", a perfectly fitting name for the infinite loop.

Of course, in an ideal world you'd have a "forever" keyword instead, but using up an entire keyword just for this one specific kind of loop seems a little excessive. So for(;;) seems like the perfect balance between idealism and practicality to me.

Just my $0.02.


T

-- 
"No, John.  I want formats that are actually useful, rather than over-featured megaliths that address all questions by piling on ridiculous internal links in forms which are hideously over-complex." -- Simon St. Laurent on xml-dev
April 29, 2016
On 28.04.2016 22:01, Seb wrote:
>
> I agree with the other people on this list - cleaning up a language is
> great and should be done.
> `++` might be a bad example, but (empty) C-style for loops are!

Leave those alone.
April 28, 2016
On Thursday, 28 April 2016 at 22:37:41 UTC, H. S. Teoh wrote:
> Of course, in an ideal world you'd have a "forever" keyword instead, but using up an entire keyword just for this one specific kind of loop seems a little excessive.

forever: {
  // stuff
  goto hell; // who needs break?????
  // more stuff
} goto forever;
hell:
 {}


April 29, 2016
On Thursday, 28 April 2016 at 18:53:21 UTC, Steven Schveighoffer wrote:
> grrr... and they removed C-style for statements (i.e. for(;;))

I can understand wanting to remove bad ideas, but 1) removing something this fundamental to the language and 2) removing something that not only doesn't lead to bad code and has technical merits makes this completely baffling and unacceptable.

Looking at the proposal to remove it, https://github.com/apple/swift-evolution/blob/master/proposals/0007-remove-c-style-for-loops.md, if you read between the lines it seems the main reason they wanted to remove it was to reduce the need for ++ and --.
April 28, 2016
On 4/28/2016 2:32 PM, Daniel Kozak via Digitalmars-d wrote:
> Wierd, I am almost sure it does not work for me last time when I tried :)

That's because in dmd there's the line:

    if (strcmp(user, "Daniel") == 0)
	setScoping(false);

It's a feature!

April 29, 2016
On Friday, 29 April 2016 at 01:36:26 UTC, Walter Bright wrote:
>
> That's because in dmd there's the line:
>
>     if (strcmp(user, "Daniel") == 0)
> 	setScoping(false);
>
> It's a feature!

That one was really funny!
... or maybe I am just thinking this because it is 3 am here...
April 28, 2016
On Thu, Apr 28, 2016 at 10:49:19PM +0000, Adam D. Ruppe via Digitalmars-d wrote:
> On Thursday, 28 April 2016 at 22:37:41 UTC, H. S. Teoh wrote:
> >Of course, in an ideal world you'd have a "forever" keyword instead, but using up an entire keyword just for this one specific kind of loop seems a little excessive.
> 
> forever: {
>   // stuff
>   goto hell; // who needs break?????
>   // more stuff
> } goto forever;
> hell:
>  {}

Armed with goto, we can completely dispense with complicated, hard-to-maintain, and trick-to-use superfluous language constructs like for, if, while, switch, and so on. Who needs if/else and that convoluted issue of dangling else's, when you could just write goto and be absolutely clear what exactly is to happen to control flow? And we can finally jettison throw, thereby eliminating the need for those cumbersome nothrow annotations and @nogc issues with creating new Exception objects.  This will reduce the size of the language, make the compiler easier to maintain, make external parsers easier to write, etc.. Sounds like win-win to me.  Who's up for drafting up the DIP? :-P


T

-- 
Only boring people get bored. -- JM