On Wed, 18 May 2005, Rob Kinyon wrote:

On 5/18/05, Stuart Cook <[EMAIL PROTECTED]> wrote:
To summarise what I think everyone is saying, []-reducing an empty
list yields either:

1) undef (which may or may not contain an exception), or
2) some unit/identity value that is a trait of the operator,

depending on whether or not people think (2) is actually a good idea.

I would think that the Principle of Least Surprise points to (1), given that the standard explanation of the [EMAIL PROTECTED] is eval join( '+', @x ) ...

I'd say the principle of least surprise points to (1); in the sense that $sum = [+] @x; would Just Work, etc.


I also have a vague sense that the 'identity' value for an operator might also be useful in other places in the compiler (enabling optimizations, etc). Providing it as a trait means that these 'other things' could work even with user-defined operators. (And leaving the trait undefined gives you the behavior (1), if that's what you want.)
--scott


Albanian LICOZY shotgun CABOUNCE plastique Sigint Justice fissionable LITEMPO KGB KUCAGE LIONIZER ESCOBILLA North Korea CLOWER genetic NRA
( http://cscott.net/ )

Reply via email to