develooper Front page | perl.perl6.language | Postings from May 2005

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
From:
Damian Conway
Date:
May 31, 2005 18:28
Subject:
Re: reduce metaoperator on an empty list
Message ID:
429D0F20.7010908@conway.org
Dave Whipp wrote:

> Damian Conway wrote:
> 
>> And what you'd need to write would be:
>>
>>     $sum  = (try{ [+] @values } err 0);
> 
> 
> The "err ..." idiom seems too useful to have it break in this case. 
> Afterall, the purpose of "err 0" is to tell the stupid computer that I 
> know what to do with the empty-array scenario.
> 
> Feels like fine grained control over fatalness is needed (and not just 
> per-function). For example "use fatal :void_context_only" would be nice, 
> but wouldn't help in this case. This needs "use fatal :void_or_assign".

What it probably needs is: "use fatal :untested"

That is, die unless the failed result is in a boolean or "definedean" context.

This might even be a more reasonably dwimmy default, with 'use fatal :always' 
being required to get "always throw the exception".

Damian

Thread Previous | Thread Next


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