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

Jens Bauer via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 18 14:54:15 PST 2015


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 first test of the 
while would be the 'if'.

In the while(1) example, the character 'c' would perhaps be a 
number the first time.
On the second iteration, the character would be allowed to be a 
letter.

However, in the original 'proposal', the loops would be 
'tighter'; the kind would be found first, and then the 'width' of 
that kind second, and when the end of the kind was reached, the 
while-block would be exited.
So in other words:
First check: Is it a number; if so, get the entire number... If 
not, try the second check: is it a token; if so, get the entire 
token, otherwise let us know that it's something unknown (but 
only if we're debugging).


More information about the Digitalmars-d mailing list