Nathan Torkington wrote:
> Your [Jeremy's] RFC says:
> > Currently, operators applied to lists in a list context behave
> > counter-intuitively:
>
> Counter-intuitively is different from consistently.  Your title is
> misleading.  Perl's ops *are* applied consistently: they consistently
> give their arguments scalar context (except for the short-circuiting
> logops, which I'd like to fix by making them return the useful lists
> instead of possibly a list or a scalar).
>
You're right. If RFC 45 is implemented they would however be inconsistent.
Anyway, I'll change the title in the next version.

> > The proposal to handle functions is tricky, since there is currently no
> > obvious way to see whether a function is going to return a list. Either
we
> > need some kind of more advanced prototyping (or other way of creating a
> > signature), or we need to manually change functions provided with Perl
to
> > check for list context and Do The Right Thing.
>
> I assume you're talking about:
>
>   @r = func1() + func2();
>
No, I'm talking about:

  @r = abs(@r);

It would be nice if we could see from a function's signature that it did not
provide a list context return, and accepted scalar parameters, so that we
could automatically make this kind of notation 'just work'. Another approach
would be to add explicit context checks into all scalar functions that come
with Perl, and have them behave in this way. This seems a bit Non-Lazy
though...
>
> Can anyone else think of existing code that would break?
>
No, but I'm probably not trying hard enough ;-)


Reply via email to