On Mon, Jun 27, 2022 at 7:28 PM Dan Book <grinnz@gmail.com> wrote: > 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 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 > I agree with that. What I'm saying is that we shouldn't *add* to the issue. At least if you export a sub which returns the data structure itself, you have the option of cloning that structure or marking it read-only. If we export variables, they would be much safer if they were read-only by default, but with an option to mutate (e.g., you have to ask for the lack of safety instead of making it the default): lexically_export '$VAR' :mutable => \my $scalar Otherwise, my vote would be to not support exporting them. Best, Curtis "Ovid" Poe CTO, All Around the World World-class software development and consulting https://allaroundtheworld.fr/Thread Previous | Thread Next