develooper Front page | perl.perl6.language | Postings from September 2002

RE: Regex query

From:
David Whipp
Date:
September 20, 2002 14:17
Subject:
RE: Regex query
Message ID:
F0DF160193C9D511B7110050DA8B7C244F4912@msexchange.intranet.fast-chip.com
Larry wrote:
> : 	$shouldbe3 = (1,2,3) + 0;
> 
> It's 3, though not for the reason a Perl 5 programmer would think.
> (In Perl 6 it's the length of the anonymous array, not the 
> last value.)

This kind of clever magic always makes me nervous:
it introduces subtle bug potentials.

  (7,8,9) == 3 # true
  (7,8)   == 2 # true
  (7)     == 1 # false
  ()      == 0 # true?

As someone who regularly writes code generators -- and even as
someone who occasionally edits code without thinking straight,
I am certain that I will, on occasion, introduce bugs through
this mechanism. If the [] list-ref composers are to remain,
there seems no good reason to add a redundant behaviour to
parentheses. Or am I missing something?


Dave.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About