> On Sat, Sep 21, 2002 at 11:36:49AM -0600, John Williams wrote:
> > On Sat, 21 Sep 2002, Jonathan Scott Duff wrote:
> > 
> > Anyway, (7) or (3+4) should yield a number, not a list, because
> > otherwise every math expression will break.
> 
> Why can't perl be smart enough to figure out what we mean?  Something
> along these lines:
>  (7)  # list context
>  (3+4)        # numeric context (there's a numeric operator in there)
>  (3+4,5)      # list context (comma trumps the numeric op)

It would be a total nightmare to try to DWIM in this case, especially 
with userdefined operators or more complex expressions.


There are 101 reasons why parens shouldn't make lists and how it can 
make mathematical expressions do something totally unexpected.

Consider changing a program where you have many mathematical 
expressions.

$x = $y / (($a + $b) * $c - $d);

If you later find out that $b or $d can be left out, I expect to be 
able to just remove it without need to check if any parentheses now 
contains only one value, and then to remove parens also.

Also machine-generated expressions would have to be double-checked 
for any single values in parentheses. Latest Perl-Golf tournament 
'Infix to RPN' used testcases like

(18*16*16*5-1+12+15+18*1-8+6/7-6-2-(19)*(17))+8+((9/14))

This is valid mathematical expression in perl5 but would do something 
totally different in perl6 because of those 'one-element lists'

-- 
Markus Laire 'malaire' <[EMAIL PROTECTED]>


Reply via email to