develooper Front page | perl.perl6.language | Postings from March 2003

Statement modifiers (yes, again)

Thread Next
Matthijs van Duin
March 18, 2003 13:04
Statement modifiers (yes, again)
Message ID:
I just read Piers' summary:
>Matthijs van Duin wondered if the issue of multiple statement modifiers
>has been settled. The thread is long, and the answer is essentially (and
>authoritatively) "Yes, it's settled. No, you can't do it." So, unless
>Larry changes his mind the point is moot.

So apparently I haven't presented my point in that thread very well

Don't get me wrong, if the answer is "no" then that settles it for me, but 
most of the thread was not about multiple statement modifiers at all.  So 
it's the wrong question that has been answered.

To summarize what I said:
1. Has the issue of multiple modifiers been settled (answer: yes it has, 
   by Larry, and the answer is "no")
2. If multiple modifiers aren't done, how about <insert proposal>

It's point 2, that proposal I'd like feedback on:  to replace the 
conditional statement modifiers (if, unless, when) by lowest-precedence 
left-associative operators, leaving only loops and topicalizers (for, 
while, given) as statement modifiers.

To save people from having to re-read the thread, here is the actual 
proposal in detail again:

  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.

  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

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

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About