return 0 or return bare

pierre masci piemas25 at gmail.com
Thu Dec 13 12:52:06 GMT 2012


Annoying indeed. You'd have to do this all the time :
my %hash = (foo => scalar foo());


On Thu, Dec 13, 2012 at 12:45 PM, Aaron Crane <perl at aaroncrane.co.uk> wrote:

> pierre masci <piemas25 at gmail.com> wrote:
> > And now i'm thinking that a scalar function should maybe throw an
> exception
> > when called in list context; for the reason mentioned above.
>
> I suspect that would be extremely annoying in practice.
>
> sub foo {
>     confess "Scalar-only routine called in list context" if wantarray;
>     ...
> }
>
> # Now this throws an exception:
> my %hash = (foo => foo());
>
> --
> Aaron Crane ** http://aaroncrane.co.uk/
>


More information about the london.pm mailing list