develooper Front page | perl.perl5.porters | Postings from June 2015

Re: For 5.24: suggested incompatible changes

Thread Previous
From:
Paul "LeoNerd" Evans
Date:
June 28, 2015 14:27
Subject:
Re: For 5.24: suggested incompatible changes
Message ID:
20150628152717.5cf5cee0@shy.leonerd.org.uk
On Sun, 28 Jun 2015 16:06:41 +0200
Aristotle Pagaltzis <pagaltzis@gmx.de> wrote:

> The only prototypes I consider at all sane to use are () and (&@), and
> the latter isn’t sane so much as too useful to throw away entirely. If
> there were a generalised way of achieving the same thing as part of
> the regular language, rather than having to introduce it through the
> side door using a prototype, I would immediately stop using that
> prototype too, and a variety of APIs I’ve created or seen could
> immediately become better, because the bare block syntax would then
> be available in method calls as well as function calls.

I too find (&@) a unique rare exception to the general mantra of "don't
use prototypes". E.g. my entire List::UtilsBy module is populated by
subs using this prototype.

I have occasionally wondered if there'd be a nicer way to do that, and
also somehow manage to cope with making more than just the first
position special. I have at times wanted a two-block generic sort-like
function, which can take a key block much like sort_by and a comparison
block much like regular sort.

Most cases of (&@) prototype that currently exist effectively guarantee
by specification that the passed sub won't escape the current
invocation of the function. As such, it might be possible that any
mechanism that replaces it would be able to respect this by not
creating a full sub, but a lighter block; allowing such higher-order
functions to be implemented with an efficiency approaching that of
core's grep and map.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk
http://www.leonerd.org.uk/  |  https://metacpan.org/author/PEVANS

Thread Previous


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