develooper Front page | perl.perl5.porters | Postings from September 2014

[perl #20510] lvalue references would be nice

Thread Previous
From:
Father Chrysostomos via RT
Date:
September 22, 2014 22:59
Subject:
[perl #20510] lvalue references would be nice
Message ID:
rt-4.0.18-22891-1411426775-1448.20510-15-0@perl.org
On Mon Sep 22 15:23:08 2014, perl.p5p@rjbs.manxome.org wrote:
> * Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-09-
> 21T16:35:33]
> > If *Other::x = \$y sets the imported flag, should \$Other::x = \$y do
> > the
> > same?
> 
> Boy, that's a good question!

I have an even harder question regarding state variables, but it will take me some time to formulate it perspicuously.

> When I started thinking, I thought yes.  I convinced myself otherwise.
> 
> \$x = \$y has, in this hypothetical future, a clear meaning.  Having
> it turn on
> the imported flag muddies its behavior.  I can think of it causing,
> but not
> alleviating, confusion.  If the mark-imported is desired, it can be
> gotten in a
> separate, explicit step... and I can imagine not always desiring it.
> 
> Do you see some real value that I am missing?

I thought that perhaps exporter modules might switch to \&ThatPackage::foo = \&foo some day, to avoid the weird *foo = \&bar syntax (which was poorly designed IMO, since the lhs and rhs are not equal after the assignment).  We would need the imported flag to be turned on in that case.  I drew that conclusion only after asking the question.

Also, it’s easier to implement, since \$x=\$y where $x is a package var can just call the same internal function that ref-to-glob assignment uses.

Turning on the flag is what the implementation on the sprout/lvref branch currently does.  (It only works for scalars as yet.)

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=20510

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