Re: Statement modifiers (yes, again)

2003-03-19 Thread Matthijs van Duin
On Tue, Mar 18, 2003 at 08:53:23PM -0700, Luke Palmer wrote:
How is a left-associative operator less special than a non-associative 
one?
Ehm, most operators in perl are left-associative, so you probably mean R2L 
short-circuiting but even then I'm not sure what you're trying to say here


And you speak of consistency, but wouldn't it be better to have Cif
be consistent with Cfor and Cwhile rather than Cand and Cor?
(Seeing as Cif is explicitly a control-flow construct)
'and' is a flow-control construct too..  foo if bar  and  bar and foo  
work identically.  Behaviorally 'if' is grouped with 'and'.

But I suppose based on the name people will group the 'if' modifier with 
'for' rather than with 'and'..

   Then they'll assume they can do:
   FOO for @BAR while $BAZ;
dunno.. people try all sorts of things that can't actually be done, but I 
suppose in this case it's a plausible extrapolation.

I guess to be honestly consistent all modifiers would have to become 
operators, which would bring us back to the multiple statement modifiers 
to which Larry said no..

I'll rest my case

--
Matthijs van Duin  --  May the Forth be with you!


Re: Statement modifiers (yes, again)

2003-03-18 Thread Luke Palmer
 To save people from having to re-read the thread, here is the actual 
 proposal in detail again:
 
 PROPOSAL
   Replace the 'if', 'unless', 'when' statement modifiers by identically 
   named lowest-precedence left-associative operators that short-circuit 
   from right to left.
 
   This means 'FOO if BAR' is identical to 'BAR and FOO', except it has a 
   lower precedence, and 'FOO unless BAR' is identical to 'BAR or FOO', 
   except it has a lower precedence. FOO and BAR are arbitrary expressions.
   Because of left-associativity, 'FOO if BAR if BAZ' is identical to
   'BAZ and BAR and FOO'.
 
   'FOO when BAR' is similar to 'FOO if BAR' except BAR is matched magically 
   like the rhs of the ~~ operator and an implicit 'break' occurs if true.
 
 RATIONALE
   1. it doesn't hurt anything: existing use of the modifiers (now operators) 
  remains functionally the same.
   2. it allows new useful expressions
   3. it is more consistent: 'if' has no reason being more special than 'and',
   4. it shouldn't make parsing more difficult

This seems like it's just begging the question.  How is a
left-associative operator less special than a non-associative one?
And you speak of consistency, but wouldn't it be better to have Cif
be consistent with Cfor and Cwhile rather than Cand and Cor?
(Seeing as Cif is explicitly a control-flow construct)

So it's really a consistency thing.  If people notice they can do:

FOO if $BAR if $BAZ;

Then they'll assume they can do:

FOO for @BAR while $BAZ;

Which they can't.

our answer is no if says Larry: so unless .doesnt;

Luke