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:
Dan Book
Date:
June 27, 2022 17:28
Subject:
Re: Pre-RFC: A built-in ability for lexical import/export
Message ID:
CABMkAVWRFM_1MALMoLoCcnz89g3X8tFwWncVHHRkjECESssv-Q@mail.gmail.com
On Mon, Jun 27, 2022 at 1:11 PM Ovid <curtis.poe@gmail.com> wrote:

> On Mon, Jun 27, 2022 at 5:30 PM Paul "LeoNerd" Evans <
> leonerd@leonerd.org.uk> wrote:
>
>> >   * Should it support things other than functions? Should we support
>> >
>> >       lexically_export VAR => \my $scalar;
>>
>> And this.
>>
>
> I'm concerned about this. Lexical import is designed to limit things to
> the current scope and not expose them to the outside world. Because you're
> exporting a reference, it's effectively a global variable. If more than one
> bit of code imports that reference and alters it, other bits of code might
> have already taken decisions based on that data, but the assumptions it
> relied on are no longer true.
>
> I've just spent several days chasing down a bug that's caused by this and
> I've had to do so multiple times for my current client. My client is losing
> money paying me to fix design flaws rather than build the new features they
> want. I'd rather not add another feature to Perl which encourages this
> practice.
>

I don't entirely agree. It's no different in semantics to passing a
variable to a function, which then has an alias to the variable to operate
on.

-Dan

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