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
Paul "LeoNerd" Evans
June 27, 2022 15:29
Re: Pre-RFC: A built-in ability for lexical import/export
Message ID:
On Mon, 27 Jun 2022 14:40:15 +0100
"Paul \"LeoNerd\" Evans" <> 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:

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

Paul "LeoNerd" Evans      |  |

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About