Re: while(...){ ... }else ...

2015-01-18 Thread deadalnix via Digitalmars-d
On Sunday, 18 January 2015 at 18:16:47 UTC, Marc Schütz wrote: Unfortunately, this would break existing code: if(some_condition) while(some_other_condition) { // ... } else // ... Currently, the `else` branch belongs to the `if`; with your proposal,

Re: while(...){ ... }else ...

2015-01-18 Thread ketmar via Digitalmars-d
On Sun, 18 Jan 2015 23:20:43 + Jens Bauer via Digitalmars-d wrote: > -A rejection will not stop me from making another proposal, > though - in fact, I do have one more. ;) sure, you're welcome! this one is not so good, but another one may be brilliant. and even if it will not be so brilliant

Re: while(...){ ... }else ...

2015-01-18 Thread ketmar via Digitalmars-d
On Sun, 18 Jan 2015 23:16:11 + Jens Bauer via Digitalmars-d wrote: > I'd like to give an example on a different use of the same > feature: > > while(length--) > { > *d++ = *s++; > } > if(length == -1) /* the programmer will need to know the value > of length here. */ > { > /* ha

Re: while(...){ ... }else ...

2015-01-18 Thread MattCoder via Digitalmars-d
; if so, get the entire token, otherwise let us know that it's something unknown (but only if we're debugging). Alright I see the purpose about: "while(){}else(){}", but unfortunately D doesn't have this. Anyway looking at your first post, I'd like to sugge

Re: while(...){ ... }else ...

2015-01-18 Thread Jens Bauer via Digitalmars-d
On Sunday, 18 January 2015 at 23:06:27 UTC, ketmar via Digitalmars-d wrote: it will introduce a new keyword, and it will break any code which using "otherwise" as identifier. as far as i can tell this (introducing new keyword) is one of the hardest thing to do, 'cause Walter will reject it wit

Re: while(...){ ... }else ...

2015-01-18 Thread Jens Bauer via Digitalmars-d
I'd like to give an example on a different use of the same feature: while(length--) { *d++ = *s++; } if(length == -1) /* the programmer will need to know the value of length here. */ { /* handle case where length was exactly 0, it's now -1 */ } would become: while(length--) { *d

Re: while(...){ ... }else ...

2015-01-18 Thread ketmar via Digitalmars-d
On Sun, 18 Jan 2015 22:56:23 + Jens Bauer via Digitalmars-d wrote: > On Sunday, 18 January 2015 at 18:16:47 UTC, Marc Schütz wrote: > > Unfortunately, this would break existing code: > > That is absolutely correct. Good catch. I did not think of that > particular case. > > However... What

Re: while(...){ ... }else ...

2015-01-18 Thread Andrei Alexandrescu via Digitalmars-d
"Jens Bauer" wrote: > On Sunday, 18 January 2015 at 18:16:47 UTC, Marc Schütz wrote: >> Unfortunately, this would break existing code: > > That is absolutely correct. Good catch. I did not think of that particular > case. > > However... What if the 'else', which "belongs" to while, is named > d

Re: while(...){ ... }else ...

2015-01-18 Thread Jens Bauer via Digitalmars-d
On Sunday, 18 January 2015 at 18:16:47 UTC, Marc Schütz wrote: Unfortunately, this would break existing code: That is absolutely correct. Good catch. I did not think of that particular case. However... What if the 'else', which "belongs" to while, is named differently, for instance ... wh

Re: while(...){ ... }else ...

2015-01-18 Thread Jens Bauer via Digitalmars-d
On Sunday, 18 January 2015 at 16:03:24 UTC, MattCoder wrote: On Sunday, 18 January 2015 at 15:52:24 UTC, Jens Bauer wrote: Maybe I misunderstood your question, but what you think about this way: ... It's close, but the result would be different. The while is a combined if+while, where the fi

Re: while(...){ ... }else ...

2015-01-18 Thread via Digitalmars-d
Unfortunately, this would break existing code: if(some_condition) while(some_other_condition) { // ... } else // ... Currently, the `else` branch belongs to the `if`; with your proposal, it would belong to the `while`. An `else` always attaches to t

Re: while(...){ ... }else ...

2015-01-18 Thread MattCoder via Digitalmars-d
On Sunday, 18 January 2015 at 15:52:24 UTC, Jens Bauer wrote: ... Ah, much more readable. Maybe I misunderstood your question, but what you think about this way: while(1){ if(c >= '0' && c <= '9') { /* number */ c = *s++; ... do something with c ... }

while(...){ ... }else ...

2015-01-18 Thread Jens Bauer via Digitalmars-d
I've sometimes wished for a while ... else combination in C. -But I never got around to proposing my suggestion to whoever or whatever committee is in charge of the C language. But since D is a language that has much more freedom regarding implementation, I'd like to sugge