On Tue, 30 Apr 2002, Jim Cromie wrote:
 
> so, assuming we have;
> 
> print 'you gave me: @wordlist = ';    # single quote - no interpolation
> 
> for @words -> $it {
>     print;
>     FIRST { print '(' }    # provisionally
>     NEXT { print ',' }
>     LAST {print ');' }
> }
> # and maybe
> else {
>     print "();\n";
> }
> 
> 
> this yields:
>         you gave me: @wordlist = ();
> or if (@wordlist) {
>         # (damn - i want to say orif ;-)
>         you gave me: @wordlist = (alpha,beta,gamma,);
> 
> whereas
> 
> print 'you gave me: @wordlist = (', join(',', @words), ")\n";
> 
> doesnt include the last comma.
> 
> if I remember the thread (now deleted, so cant be accurate)
> 
> the last comma would be in there, unlike if it were in a join.
> cuz NEXT is a block terminator, not a block-inbetweener
> 
> this is vaguely unfortunate, as its not so simple to write
> loops to generate SQL ( which isnt as friendly wrt to extra commas as 
> perl is )

I'd rather have an in-betweener block too. Loops like this are very 
common, and I hate doing "prefix" commas, if you know what I mean.  I 
realize NEXT often used for cleanup, so maybe you could introduse Yet 
Another block, BETWEEN (or SQUEEZE).

Or are we just going to have to deal with this fact?

> 
> separately ( to re-iterate earlier good thoughts ):
> 
> loop {} else {}
> 
> would be more visually distinct (easier to read) as
> 
> loop {} otherwize {}

It would be especially clear if it were spelled correctly ;)


> esp when loop block is bigger than a screenful, new keyword keeps us 
> from looking for the if,
> and it fits better with natural language (or at least dictionary language )
> 
> where the connotation is a final alternative to lots of choices.

Yes, I think that's a good idea also.  I suppose C<else> DWIMs better 
though (I've taught people C++, and many times they wonder why they can't 
put elses on loops).  I think it's really a matter of opinion. Which is, I 
suppose, why this list is here.


Luke

Reply via email to