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

Re: Pre-RFC: A built-in ability for lexical import/export

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
June 27, 2022 15:29
Subject:
Re: Pre-RFC: A built-in ability for lexical import/export
Message ID:
20220627162941.66eed20b@shy.leonerd.org.uk
On Mon, 27 Jun 2022 14:40:15 +0100
"Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> wrote:

> > Perhaps it should take a whole kv-list of name/ref pairs, so you can
> > export lots in one go:
> > 
> >   builtin::lexically_export
> >     one => \&one,
> >     two => \&two, ...  
> 
> It currently doesn't do this yet, but shouldn't be hard to add.

Update: it now does this.
> 
> In the process of writing it I've come up with some more questions, to
> which I don't have an easy answer:
> 
>   * Should it support things other than functions? Should we support
> 
>       lexically_export VAR => \my $scalar;

And this.

>   * If so, should names be sigil-prefixed?
> 
>       lexically_export '$VAR' => \my $scalar, '&func' => sub {...};

And this.

> I.e. the model being "if no sigil is specified, presume &"; and
> additionally, error if the sigil doesn't match the thing being
> referenced.

And this.

> I think this feels sane - does anyone disagree?

Thanks all for the comments (here and IRC).

Next (meta)-question: Should this be turned into a full RFC, or is it
small and concise enough that these questions and any subsequent
discussion on a PR would be sufficient?

In the hope it's the latter, I've now opened a PR for merging it:

  https://github.com/Perl/perl5/pull/19895

but if people think this should go via the full RFC process first, I
can write something up.

-- 
Paul "LeoNerd" Evans

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

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