Skip Menu |

Subject: [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 198b
The lvalue references feature, which is almost ready to be merged into blead, gives Perl 5.22.0 experimental support for aliasing via reference assignment: \$x = \$y; -- Father Chrysostomos
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 379b
On Fri Oct 10 23:53:37 2014, sprout wrote: Show quoted text
> The lvalue references feature, which is almost ready to be merged into > blead, gives Perl 5.22.0 experimental support for aliasing via > reference assignment: > > \$x = \$y;
Would it be possible for you to first post the documentation you would provide for this feature? Thank you very much. -- James E Keenan (jkeenan@cpan.org)
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 615b
On Sat Oct 11 05:10:36 2014, jkeenan wrote: Show quoted text
> On Fri Oct 10 23:53:37 2014, sprout wrote:
> > The lvalue references feature, which is almost ready to be merged > > into > > blead, gives Perl 5.22.0 experimental support for aliasing via > > reference assignment: > > > > \$x = \$y;
> > Would it be possible for you to first post the documentation you would > provide for this feature?
It’s currently at the head of the sprout/lvref branch: http://perl5.git.perl.org/perl.git/commitdiff/sprout/lvref The reason I opened this ticket was to get a number to put in perlexperiment.pod. -- Father Chrysostomos
To: perl5-porters [...] perl.org
From: Ricardo Signes <perl.p5p [...] rjbs.manxome.org>
Date: Tue, 14 Oct 2014 08:47:15 -0400
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 1.2k
* Father Chrysostomos <perlbug-followup@perl.org> [2014-10-11T02:53:37] Show quoted text
> The lvalue references feature, which is almost ready to be merged into blead, > gives Perl 5.22.0 experimental support for aliasing via reference assignment:
This sort of seemed to come out of nowhere from my perspective. Or, rather, I knew you'd been working on, and had asked one or two questions about it, but then it got merged. I was a bit taken aback. I generally look at branches hitting the commit list only lightly, on the assumption that big user-facing changes will land only after discussion. In saying, "Could we, next time, first have a public announcement that it's ready to merge and a review period?" I realize that the review period will probably garner much less review than you'd like, but I think it would be useful to do, at the cost of only a few days delay, probably. I will now begin kicking this around, anyway, and hope to find it purely awesome. Since I haven't much played with it yet, I don't have much to say, except this: I think "lvalue reference" might need to be renamed. My understanding is that it's always about the backslash on the left hand side, rather than having a reference in an lvalue. Also, we have LVALUE refs. Is this feature actually related to that? -- rjbs
Download signature.asc
application/pgp-signature 473b

Message body not shown because it is not plain text.

Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Date: Tue, 14 Oct 2014 13:56:32 +0100
From: "Paul \"LeoNerd\" Evans" <leonerd [...] leonerd.org.uk>
To: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 800b
On Tue, 14 Oct 2014 08:47:15 -0400 Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote: Show quoted text
> Since I haven't much played with it yet, I don't have much to say, > except this: I think "lvalue reference" might need to be renamed. My > understanding is that it's always about the backslash on the left > hand side, rather than having a reference in an lvalue. Also, we > have LVALUE refs. Is this feature actually related to that?
I too am a little put off by the name of what is otherwise a great idea. I suspect the problem is the subtle distinction between "lvalues that are references", and "references that are lvalues". We've always had the former; now we have the latter as well. -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk http://www.leonerd.org.uk/ | https://metacpan.org/author/PEVANS
Download signature.asc
application/pgp-signature 213b

Message body not shown because it is not plain text.

RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 696b
On Tue Oct 14 05:47:48 2014, perl.p5p@rjbs.manxome.org wrote: Show quoted text
> Since I haven't much played with it yet, I don't have much to say, > except this: > I think "lvalue reference" might need to be renamed. My understanding > is that > it's always about the backslash on the left hand side, rather than > having a > reference in an lvalue.
‘Assigning to references’ is the least ambiguous way to refer to it that I can think. How do we abbreviate that into a feature name? If we call it refassign, it’s ambiguous again, because reference assignment would be assignment of references. Show quoted text
> Also, we have LVALUE refs. Is this feature > actually > related to that?
No. -- Father Chrysostomos
To: perl5-porters [...] perl.org
From: "Paul \"LeoNerd\" Evans" <leonerd [...] leonerd.org.uk>
Date: Tue, 14 Oct 2014 15:43:40 +0100
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 512b
On Tue, 14 Oct 2014 08:47:15 -0400 Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote: Show quoted text
> Also, we have LVALUE refs. Is this feature actually > related to that?
The things we have that are called LVALUE are the lvalues returned by the substr() function so that mutations of it can affect the original: my $str = "Hello world"; substr( $str, 0, 5 ) = "Goodbye"; <== assignment to an LVALUE -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk http://www.leonerd.org.uk/ | https://metacpan.org/author/PEVANS
Download signature.asc
application/pgp-signature 213b

Message body not shown because it is not plain text.

To: perl5-porters [...] perl.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
Date: Tue, 14 Oct 2014 17:06:57 +0200
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 2.7k
On Tue, 14 Oct 2014 15:43:40 +0100, "Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> wrote: Show quoted text
> On Tue, 14 Oct 2014 08:47:15 -0400 > Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote: >
> > Also, we have LVALUE refs. Is this feature actually > > related to that?
> > The things we have that are called LVALUE are the lvalues returned by > the substr() function so that mutations of it can affect the original: > > my $str = "Hello world"; > substr( $str, 0, 5 ) = "Goodbye"; <== assignment to an LVALUE
is that (internally) different from using the 4-arg form (which I prefer because it is much faster)? $ perl -wE'$_="Foo";substr $_,1,0,"x";say' Fxoo $ perl -wE'$_="Foo";substr($_,1,0)="x";say' Fxoo B says no $ perl -MO=Concise -wE'$_="Foo";substr($_,1,0)="x";say' g <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 47 -e:1) v:%,{,469764096 ->3 5 <2> sassign vKS/2 ->6 3 <$> const[PV "Foo"] s ->4 - <1> ex-rv2sv sKRM*/1 ->5 4 <#> gvsv[*_] s ->5 6 <;> nextstate(main 47 -e:1) v:%,{,469764096 ->7 - <1> ex-sassign vKS/2 ->c b <@> substr[t3] vKS/REPL1ST,3 ->c - <0> ex-pushmark s ->8 7 <$> const[PV "x"] s ->8 - <1> ex-rv2sv sKRM*/1 ->9 8 <#> gvsv[*_] s ->9 9 <$> const[IV 1] s ->a a <$> const[IV 0] s ->b c <;> nextstate(main 47 -e:1) v:%,{,469764096 ->d f <@> say vK ->g d <0> pushmark s ->e - <1> ex-rv2sv sK/1 ->f e <#> gvsv[*_] s ->f -e syntax OK $ perl -MO=Concise -wE'$_="Foo";substr $_,1,0,"x";say' g <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 47 -e:1) v:%,{,469764096 ->3 5 <2> sassign vKS/2 ->6 3 <$> const[PV "Foo"] s ->4 - <1> ex-rv2sv sKRM*/1 ->5 4 <#> gvsv[*_] s ->5 6 <;> nextstate(main 47 -e:1) v:%,{,469764096 ->7 b <@> substr[t3] vK/4 ->c - <0> ex-pushmark s ->7 - <1> ex-rv2sv sKM/1 ->8 7 <#> gvsv[*_] s ->8 8 <$> const[IV 1] s ->9 9 <$> const[IV 0] s ->a a <$> const[PV "x"] s ->b c <;> nextstate(main 47 -e:1) v:%,{,469764096 ->d f <@> say vK ->g d <0> pushmark s ->e - <1> ex-rv2sv sK/1 ->f e <#> gvsv[*_] s ->f -e syntax OK cmpthese (-3, { arg3 => sub { my $foo = "foo"; substr ($foo, 1, 0) = "x"; }, arg4 => sub { my $foo = "foo"; substr $foo, 1, 0, "x"; }, }); Rate arg3 arg4 arg3 3235869/s -- -61% arg4 8401562/s 160% -- -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using perl5.00307 .. 5.19 porting perl5 on HP-UX, AIX, and openSUSE http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Download (untitled)
application/pgp-signature 490b

Message body not shown because it is not plain text.

Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
To: Paul LeoNerd Evans <leonerd [...] leonerd.org.uk>
Date: Tue, 14 Oct 2014 11:12:12 -0400
From: Eric Brine <ikegami [...] adaelis.com>
CC: perl5 porters <perl5-porters [...] perl.org>
Download (untitled) / with headers
text/plain 465b
On Tue, Oct 14, 2014 at 8:56 AM, Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> wrote:
Show quoted text
I too am a little put off by the name of what is otherwise a great idea.

I suspect the problem is the subtle distinction between "lvalues that
are references", and "references that are lvalues". We've always had
the former; now we have the latter as well.

Good point. It has nothing to do with modifying references as the name claims, and all to do with aliasing.


CC: ;, perl5-porters [...] perl.org
To: Father Chrysostomos via RT <perlbug-followup [...] perl.org>
From: Ricardo Signes <perl.p5p [...] rjbs.manxome.org>
Date: Tue, 14 Oct 2014 11:18:34 -0400
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 1.1k
* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-14T09:45:31] Show quoted text
> On Tue Oct 14 05:47:48 2014, perl.p5p@rjbs.manxome.org wrote:
> > Since I haven't much played with it yet, I don't have much to say, except > > this: I think "lvalue reference" might need to be renamed. My > > understanding is that it's always about the backslash on the left hand > > side, rather than having a reference in an lvalue.
> > ‘Assigning to references’ is the least ambiguous way to refer to it that I > can think. How do we abbreviate that into a feature name? If we call it > refassign, it’s ambiguous again, because reference assignment would be > assignment of references.
From the user's perspective, is there actually a reference involved in the left hand side? The assignment forces \$left to refer to the same thing as \$right, but it doesn't in anyway [that I conceive of the phrase] assign to a reference. Why not just "aliasing"? The use of \ makes sense, and can (I think) be taught easily, but I think that actually calling it a lvalue reference or an assignment to a reference begins to confuse things that are distinct. -- rjbs
Download signature.asc
application/pgp-signature 473b

Message body not shown because it is not plain text.

From: Salvador Ortiz Garcia <sog [...] msg.com.mx>
Date: Tue, 14 Oct 2014 12:39:04 -0500
To: perl5-porters [...] perl.org
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 862b
On 10/14/2014 10:06 AM, H.Merijn Brand wrote: Show quoted text
> On Tue, 14 Oct 2014 15:43:40 +0100, "Paul \"LeoNerd\" Evans" > <leonerd@leonerd.org.uk> wrote: >
>> On Tue, 14 Oct 2014 08:47:15 -0400 >> Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote: >>
>>> Also, we have LVALUE refs. Is this feature actually >>> related to that?
>> The things we have that are called LVALUE are the lvalues returned by >> the substr() function so that mutations of it can affect the original: >> >> my $str = "Hello world"; >> substr( $str, 0, 5 ) = "Goodbye"; <== assignment to an LVALUE
> is that (internally) different from using the 4-arg form (which I > prefer because it is much faster)?
If you use the lvalue returned only once, no. But: $ perl -E 'my $str = "Hello"; for(substr($str,1,1)) { say $_; $_="ee"; say $str; $_ = "aaa"; say $str }' e Heello Haaallo --- sortiz
CC: perl5 porters <perl5-porters [...] perl.org>
To: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
Date: Tue, 14 Oct 2014 13:47:35 -0400
From: Eric Brine <ikegami [...] adaelis.com>
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 956b
On Tue, Oct 14, 2014 at 11:06 AM, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:
Show quoted text
On Tue, 14 Oct 2014 15:43:40 +0100, "Paul \"LeoNerd\" Evans"
<leonerd@leonerd.org.uk> wrote:

> On Tue, 14 Oct 2014 08:47:15 -0400
> Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:
>
> > Also, we have LVALUE refs.  Is this feature actually
> > related to that?
>
> The things we have that are called LVALUE are the lvalues returned by
> the substr() function so that mutations of it can affect the original:
>
>   my $str = "Hello world";
>   substr( $str, 0, 5 ) = "Goodbye";   <== assignment to an LVALUE

is that (internally) different from using the 4-arg form (which I
prefer because it is much faster)?


Better examples:

my $ref = \substr($str, 0, 5);
$$ref = "Goodbye";

or

sub f { $_[0] = "Goodbye"; }
f( substr($str, 0, 5) );

Show quoted text
B says no

If the assignment is optimized away, why is it slower? I'll try to look into it tonight.
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
From: Bo Lindbergh <2bfjdsla52kztwejndzdstsxl9athp [...] gmail.com>
Date: Tue, 14 Oct 2014 21:01:06 +0200
To: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 356b
Quoth Paul LeoNerd Evans: Show quoted text
> I too am a little put off by the name of what is otherwise a great idea. > > I suspect the problem is the subtle distinction between "lvalues that > are references", and "references that are lvalues". We've always had > the former; now we have the latter as well.
Agreed. How about "lreferences" or "lrefs"? /Bo Lindbergh
Date: Tue, 14 Oct 2014 22:56:07 +0200
From: Leon Timmermans <fawaka [...] gmail.com>
To: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
CC: Perl5 Porters <perl5-porters [...] perl.org>
Download (untitled) / with headers
text/plain 2.2k
On Tue, Oct 14, 2014 at 5:06 PM, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:
Show quoted text
is that (internally) different from using the 4-arg form (which I
prefer because it is much faster)?

$ perl -wE'$_="Foo";substr $_,1,0,"x";say'
Fxoo
$ perl -wE'$_="Foo";substr($_,1,0)="x";say'
Fxoo

B says no

$ perl -MO=Concise -wE'$_="Foo";substr($_,1,0)="x";say'
g  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 47 -e:1) v:%,{,469764096 ->3
5     <2> sassign vKS/2 ->6
3        <$> const[PV "Foo"] s ->4
-        <1> ex-rv2sv sKRM*/1 ->5
4           <#> gvsv[*_] s ->5
6     <;> nextstate(main 47 -e:1) v:%,{,469764096 ->7
-     <1> ex-sassign vKS/2 ->c
b        <@> substr[t3] vKS/REPL1ST,3 ->c
-           <0> ex-pushmark s ->8
7           <$> const[PV "x"] s ->8
-           <1> ex-rv2sv sKRM*/1 ->9
8              <#> gvsv[*_] s ->9
9           <$> const[IV 1] s ->a
a           <$> const[IV 0] s ->b
c     <;> nextstate(main 47 -e:1) v:%,{,469764096 ->d
f     <@> say vK ->g
d        <0> pushmark s ->e
-        <1> ex-rv2sv sK/1 ->f
e           <#> gvsv[*_] s ->f
-e syntax OK

$ perl -MO=Concise -wE'$_="Foo";substr $_,1,0,"x";say'
g  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 47 -e:1) v:%,{,469764096 ->3
5     <2> sassign vKS/2 ->6
3        <$> const[PV "Foo"] s ->4
-        <1> ex-rv2sv sKRM*/1 ->5
4           <#> gvsv[*_] s ->5
6     <;> nextstate(main 47 -e:1) v:%,{,469764096 ->7
b     <@> substr[t3] vK/4 ->c
-        <0> ex-pushmark s ->7
-        <1> ex-rv2sv sKM/1 ->8
7           <#> gvsv[*_] s ->8
8        <$> const[IV 1] s ->9
9        <$> const[IV 0] s ->a
a        <$> const[PV "x"] s ->b
c     <;> nextstate(main 47 -e:1) v:%,{,469764096 ->d
f     <@> say vK ->g
d        <0> pushmark s ->e
-        <1> ex-rv2sv sK/1 ->f
e           <#> gvsv[*_] s ->f
-e syntax OK

They are not identical at all.
 
Show quoted text
cmpthese (-3, {
    arg3 => sub { my $foo = "foo"; substr ($foo, 1, 0) = "x"; },
    arg4 => sub { my $foo = "foo"; substr  $foo, 1, 0,   "x"; },
    });

          Rate arg3 arg4
arg3 3235869/s   -- -61%
arg4 8401562/s 160%   --

I agree we that in that specific (but probably common) case that could probably be optimized away.

Leon
Date: Tue, 14 Oct 2014 23:50:43 +0200
From: Aristotle Pagaltzis <pagaltzis [...] gmx.de>
To: perl5-porters [...] perl.org
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 1.6k
* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-14 15:50]: Show quoted text
> ‘Assigning to references’ is the least ambiguous way to refer to it > that I can think.
But wrong. This has been bugging me all day, because the same confusion is all over the thread, but I couldn’t put my finger on it until now. References are values, whereas lvalue context is a syntactical property of (part of) an expression. So this feature is not about references in lvalue context. It is about reference *constructors* in lvalue context: it requires a literal backslash on the left side of an assignment. So, call the feature `refconsassign` maybe? I don’t know. Personally I’m inclined to go with Rik right now, call it `varaliasing`. That is the point of the feature from a user perspective after all. OTOH that does not refer specially to a particular language mechanic for the feature, but to a user requirement, so it is more ambiguous. Basically as long as people need to spell the name of the feature it makes more sense to me to call it something like `varaliasing` so the user-facing interface is based on user-level concerns. But once it’s rolled into `use 5.24` or whichever, and becomes invisible to the user, it would make more sense to me if it were called such as `refconsassign` as that names a particular feature in the language design from the language designer perspective. And the experimental phase will hopefully be brief while the long term is, well, long. So after writing this mail I think I actually lean that way – call it `refconsassign` or `lvalue_refcons` or something along those lines. Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.3k
On Tue Oct 14 08:07:44 2014, hmbrand wrote: Show quoted text
> On Tue, 14 Oct 2014 15:43:40 +0100, "Paul \"LeoNerd\" Evans" > <leonerd@leonerd.org.uk> wrote: >
> > On Tue, 14 Oct 2014 08:47:15 -0400 > > Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote: > >
> > > Also, we have LVALUE refs. Is this feature actually > > > related to that?
> > > > The things we have that are called LVALUE are the lvalues returned by > > the substr() function so that mutations of it can affect the original: > > > > my $str = "Hello world"; > > substr( $str, 0, 5 ) = "Goodbye"; <== assignment to an LVALUE
> > is that (internally) different from using the 4-arg form (which I > prefer because it is much faster)? > > $ perl -wE'$_="Foo";substr $_,1,0,"x";say' > Fxoo > $ perl -wE'$_="Foo";substr($_,1,0)="x";say' > Fxoo > > B says no > > $ perl -MO=3DConcise -wE'$_=3D"Foo";substr($_,1,0)=3D"x";say'
... Show quoted text
> cmpthese (-3, { > arg3 => sub { my $foo = "foo"; substr ($foo, 1, 0) = "x"; }, > arg4 => sub { my $foo = "foo"; substr $foo, 1, 0, "x"; }, > }); > > Rate arg3 arg4 > arg3 3235869/s -- -61% > arg4 8401562/s 160% --
The optimisation that makes the assignment disappear only happens if it is known to be in void context at compile time. Your benchmark subs are not equivalent to the substr assignment that you fed to B::Concise. -- Father Chrysostomos
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 2.1k
On Tue Oct 14 08:18:57 2014, perl.p5p@rjbs.manxome.org wrote: Show quoted text
> * Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10- > 14T09:45:31]
> > On Tue Oct 14 05:47:48 2014, perl.p5p@rjbs.manxome.org wrote:
> > > Since I haven't much played with it yet, I don't have much to say, > > > except > > > this: I think "lvalue reference" might need to be renamed. My > > > understanding is that it's always about the backslash on the left > > > hand > > > side, rather than having a reference in an lvalue.
> > > > ‘Assigning to references’ is the least ambiguous way to refer to it > > that I > > can think. How do we abbreviate that into a feature name? If we > > call it > > refassign, it’s ambiguous again, because reference assignment would > > be > > assignment of references.
> > From the user's perspective, is there actually a reference involved in > the left > hand side?
Assignment has a return value, so yes. (Hmm. What should (\$x=\$y)=\$z do? Currently it probably does not do what anyone expects.) Show quoted text
> The assignment forces \$left to refer to the same thing as > \$right, > but it doesn't in anyway [that I conceive of the phrase] assign to a > reference. > > Why not just "aliasing"? The use of \ makes sense, and can (I think) > be taught > easily, but I think that actually calling it a lvalue reference or an > assignment to a reference begins to confuse things that are distinct.
‘Aliasing’ would work. Considering that the previous incarnation of this feature was Chip’s ‘bind’ operator, spelt := and inspired by Perl 6, maybe we could call this ‘bind’ or ‘binding’. But the syntax is very different from Perl 6’s bind operator, so maybe that would be confusing. For the record: When the bind operator was proposed, it was the difficulty in reconciling @a:=@b with @a:=[] and deciding when the rhs should automatically be dereferenced that led to \@a=\@b being preferred once more, as all the edge cases can be based on existing Perl 5 syntax that people already know. ...In case you were wondering why I didn’t just borrow the Perl 6 := operator. (This is from memory; I didn’t check the archives.) -- Father Chrysostomos
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 577b
On Tue Oct 14 12:01:32 2014, 2bfjdsla52kztwejndzdstsxl9athp@gmail.com wrote: Show quoted text
> Quoth Paul LeoNerd Evans:
> > I too am a little put off by the name of what is otherwise a great idea. > > > > I suspect the problem is the subtle distinction between "lvalues that > > are references", and "references that are lvalues". We've always had > > the former; now we have the latter as well.
> > Agreed. How about "lreferences" or "lrefs"?
I’ve been calling them lvrefs internally, if that matters. (C.f. the new lvref magic type, the lvref op, lvref.t.) -- Father Chrysostomos
To: Perl RT Bug Tracker <perlbug-followup [...] perl.org>
From: demerphq <demerphq [...] gmail.com>
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
CC: Perl5 Porteros <perl5-porters [...] perl.org>
Date: Thu, 16 Oct 2014 09:31:24 +0200
Download (untitled) / with headers
text/plain 790b
On 15 October 2014 02:38, Father Chrysostomos via RT <perlbug-followup@perl.org> wrote:
Show quoted text
On Tue Oct 14 12:01:32 2014, 2bfjdsla52kztwejndzdstsxl9athp@gmail.com wrote:
> Quoth Paul LeoNerd Evans:
> > I too am a little put off by the name of what is otherwise a great idea.
> >
> > I suspect the problem is the subtle distinction between "lvalues that
> > are references", and "references that are lvalues". We've always had
> > the former; now we have the latter as well.
>
> Agreed.  How about "lreferences" or "lrefs"?

I’ve been calling them lvrefs internally, if that matters.

(C.f. the new lvref magic type, the lvref op, lvref.t.)

Personally I think calling this aliasing is the right thing.

Yves

--
perl -Mre=debug -e "/just|another|perl|hacker/"
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
To: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
From: Kent Fredric <kentfredric [...] gmail.com>
Date: Thu, 16 Oct 2014 21:00:52 +1300
CC: pp Porters <perl5-porters [...] perl.org>
Download (untitled) / with headers
text/plain 1.1k

On 15 October 2014 04:06, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:
Show quoted text
cmpthese (-3, {
    arg3 => sub { my $foo = "foo"; substr ($foo, 1, 0) = "x"; },
    arg4 => sub { my $foo = "foo"; substr  $foo, 1, 0,   "x"; },
    });

What will really bake your noodle, put them both in void context instead of in the return at the end of a sub.

use Benchmark qw( :hireswallclock cmpthese );

cmpthese(
    -3,
    {
        arg3 => sub { my $foo = "foo"; substr( $foo, 1, 0 ) = "x";},
        arg4 => sub { my $foo = "foo"; substr $foo, 1, 0, "x";},

        arg3_void => sub { my $foo = "foo"; substr( $foo, 1, 0 ) = "x"; 1 },
        arg4_void => sub { my $foo = "foo"; substr $foo, 1, 0, "x"; 1 },
    }
);


               Rate      arg3 arg4_void      arg4 arg3_void
arg3      2278016/s        --      -61%      -65%      -66%
arg4_void 5845748/s      157%        --      -11%      -13%
arg4      6556081/s      188%       12%        --       -2%
arg3_void 6712231/s      195%       15%        2%        --



that lone '1' on the end makes a difference of 200% :D
Date: Thu, 16 Oct 2014 16:09:45 +0100
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
From: "Paul \"LeoNerd\" Evans" <leonerd [...] leonerd.org.uk>
To: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 256b
On Thu, 16 Oct 2014 09:31:24 +0200 demerphq <demerphq@gmail.com> wrote: Show quoted text
> Personally I think calling this aliasing is the right thing.
+1 -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk http://www.leonerd.org.uk/ | https://metacpan.org/author/PEVANS
Download signature.asc
application/pgp-signature 213b

Message body not shown because it is not plain text.

RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 405b
On Thu Oct 16 08:10:18 2014, leonerd@leonerd.org.uk wrote: Show quoted text
> On Thu, 16 Oct 2014 09:31:24 +0200 > demerphq <demerphq@gmail.com> wrote: >
> > Personally I think calling this aliasing is the right thing.
> > +1
Aristotle suggested ‘varaliasing’, but that name is not so good, as it does not cover \&x = \&y. I think ‘aliasing’ is good. Shall I go ahead and change it? -- Father Chrysostomos
Date: Fri, 17 Oct 2014 16:31:20 +0200
To: perl5-porters [...] perl.org
From: Aristotle Pagaltzis <pagaltzis [...] gmx.de>
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 520b
* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-17 00:55]: Show quoted text
> Aristotle suggested ‘varaliasing’, but that name is not so good, > as it does not cover \&x = \&y. > > I think ‘aliasing’ is good.
Hrm, good point. Maybe `bind` (taking a page from Chip)? Has the advantage of being extremely short yet unambiguous enough, too. What bugs me about `aliasing` just by itself is that it could be referring to so many things. My suggestion was an attempt to fix that, but evidently did not go so well.
Date: Fri, 17 Oct 2014 11:12:57 -0400
From: Ricardo Signes <perl.p5p [...] rjbs.manxome.org>
To: Father Chrysostomos via RT <perlbug-followup [...] perl.org>
CC: ;, perl5-porters [...] perl.org
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 581b
* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-16T18:51:17] Show quoted text
> I think ‘aliasing’ is good. Shall I go ahead and change it?
That's fine with me. If you wanted something more specific than "aliasing", which I could understand, I'd suggest that the salient detail of this aliasing is not the backwhack on the lhs, but the fact that it's done with the assignment operator. I'd then go with assign_alias or something formed from those two parts. I think I am happy to let you name the thing, as long as you don't name it that thing I didn't like. ;) -- rjbs
Download signature.asc
application/pgp-signature 473b

Message body not shown because it is not plain text.

RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 261b
On Fri Oct 17 07:31:49 2014, aristotle wrote: Show quoted text
> What bugs me about `aliasing` just by itself is that it could be > referring to so many things.
I can’t think of what else it could be referring to in the context of Perl programming. -- Father Chrysostomos
Date: Fri, 17 Oct 2014 19:16:57 +0200
From: Eirik Berg Hanssen <Eirik-Berg.Hanssen [...] allverden.no>
To: "perlbug-followup [...] perl.org" <perlbug-followup [...] perl.org>
CC: Perl5 Porters <perl5-porters [...] perl.org>
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 756b
On Fri, Oct 17, 2014 at 6:29 PM, Father Chrysostomos via RT <perlbug-followup@perl.org> wrote: Show quoted text
> On Fri Oct 17 07:31:49 2014, aristotle wrote:
>> What bugs me about `aliasing` just by itself is that it could be >> referring to so many things.
> > I can’t think of what else it could be referring to in the context of Perl programming.
For(each) loop variable ("implicit alias for each item"), glob assignment ("symbol table aliasing"), @_ ("aliases for the actual scalar parameters"). This I might describe as reference assignment, analogous to glob assignment. Hey, that's what you called it in the OP. :) ("aliasing via reference assignment", "aliasing via for(each) loops", "aliasing via glob assignment", "aliasing via @_" ...) Eirik
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
On Fri Oct 17 10:17:19 2014, Eirik-Berg.Hanssen@allverden.no wrote: Show quoted text
> On Fri, Oct 17, 2014 at 6:29 PM, Father Chrysostomos via RT > <perlbug-followup@perl.org> wrote:
> > On Fri Oct 17 07:31:49 2014, aristotle wrote:
> >> What bugs me about `aliasing` just by itself is that it could be > >> referring to so many things.
> > > > I can’t think of what else it could be referring to in the context of > > Perl programming.
> > For(each) loop variable ("implicit alias for each item"), glob > assignment ("symbol table aliasing"), @_ ("aliases for the actual > scalar parameters").
Yes, what distinguishes this is the *means* of aliasing, though it is all ultimately the same thing underneath. Show quoted text
> This I might describe as reference assignment, analogous to glob > assignment. > > Hey, that's what you called it in the OP. :) > > ("aliasing via reference assignment", "aliasing via for(each) > loops", "aliasing via glob assignment", "aliasing via @_" ...)
So how about refaliasing? (I.e., aliasing via reference.) Ricardo Signes wrote: Show quoted text
> I'd then go with assign_alias or something formed from those two parts.
But for \@x ( @array_of_arrays ) has no assignment in it. -- Father Chrysostomos
CC: ;, perl5-porters [...] perl.org
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Date: Fri, 17 Oct 2014 16:25:15 -0400
To: Father Chrysostomos via RT <perlbug-followup [...] perl.org>
From: Ricardo Signes <perl.p5p [...] rjbs.manxome.org>
Download (untitled) / with headers
text/plain 377b
* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-17T15:52:59] Show quoted text
> So how about refaliasing? (I.e., aliasing via reference.)
That sounds better than anything so far. Show quoted text
> Ricardo Signes wrote:
> > I'd then go with assign_alias or something formed from those two parts.
> > But for \@x ( @array_of_arrays ) has no assignment in it.
I stand corrected! -- rjbs
Download signature.asc
application/pgp-signature 473b

Message body not shown because it is not plain text.

RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 262b
On Fri Oct 17 08:13:20 2014, perl.p5p@rjbs.manxome.org wrote: Show quoted text
> I think I am happy to let you name the thing, as long as you don't > name it that > thing I didn't like. ;)
Very well. I have renamed it ‘parsnip’ in commit baabe3f. -- Father Chrysostomos
Date: Sat, 18 Oct 2014 10:35:31 -0400
To: Father Chrysostomos via RT <perlbug-followup [...] perl.org>
From: Ricardo Signes <perl.p5p [...] rjbs.manxome.org>
CC: ;, perl5-porters [...] perl.org
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
Download (untitled) / with headers
text/plain 169b
* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-17T23:29:29] Show quoted text
> Very well. I have renamed it ‘parsnip’ in commit baabe3f.
How seasonal! -- rjbs
Download signature.asc
application/pgp-signature 473b

Message body not shown because it is not plain text.

Date: Sat, 18 Oct 2014 11:05:41 -0400
Subject: Re: [perl #122947] [EXPERIMENT] Lvalue references
To: perl5-porters [...] perl.org
From: Uri Guttman <uri [...] stemsystems.com>
Download (untitled) / with headers
text/plain 308b
On 10/18/2014 10:35 AM, Ricardo Signes wrote: Show quoted text
> * Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-17T23:29:29]
>> Very well. I have renamed it ‘parsnip’ in commit baabe3f.
> How seasonal! >
if you had another branch with that, you could call it a parsnip in a pair tree. <ducks> uri
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 145b
Are the perl5-porters prepared to now formally 'accept' this experimental feature, so that it will become supported and non-experimental in 5.24?
RT-Send-CC: perl5-porters [...] perl.org
...er I mean 5.26
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 492b
On Fri Sep 30 09:03:55 2016, ed wrote: Show quoted text
> Are the perl5-porters prepared to now formally 'accept' this > experimental feature, so that it will become supported and non- > experimental in 5.24?
No. There is still a serious bug in it, and fixing it may require the behaviour to change incompatibly. If someone would like to implement what I outlined in 514e62e37b8, then after that it could be accepted. I myself no longer have the tuits for the forseeable future. -- Father Chrysostomos
From: Sawyer X <xsawyerx [...] gmail.com>
Date: Sat, 15 Oct 2016 15:27:31 +0200
To: perlbug-followup [...] perl.org
Subject: Re: [perl #122947] [EXPERIMENT] Aliasing via reference
Download (untitled) / with headers
text/plain 574b
On 09/30/2016 09:35 PM, Father Chrysostomos via RT wrote: Show quoted text
> On Fri Sep 30 09:03:55 2016, ed wrote:
>> Are the perl5-porters prepared to now formally 'accept' this >> experimental feature, so that it will become supported and non- >> experimental in 5.24?
> No. There is still a serious bug in it, and fixing it may require the behaviour to change incompatibly. > > If someone would like to implement what I outlined in 514e62e37b8, then after that it could be accepted. I myself no longer have the tuits for the forseeable future. >
Is there a specific ticket for that?
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 719b
On Sat, 15 Oct 2016 06:28:07 -0700, xsawyerx@gmail.com wrote: Show quoted text
> On 09/30/2016 09:35 PM, Father Chrysostomos via RT wrote:
> > On Fri Sep 30 09:03:55 2016, ed wrote:
> >> Are the perl5-porters prepared to now formally 'accept' this > >> experimental feature, so that it will become supported and non- > >> experimental in 5.24?
> > No. There is still a serious bug in it, and fixing it may require > > the behaviour to change incompatibly. > > > > If someone would like to implement what I outlined in 514e62e37b8, > > then after that it could be accepted. I myself no longer have the > > tuits for the forseeable future. > >
> > Is there a specific ticket for that?
There is now: #130263. -- Father Chrysostomos
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 689b
Hello, I recently play[1] with refaliasing to fix Kavorka on Perl >= 5.24[2]. As far as I understand in the documentation, with something like \my(@a) = \(@b); each element in @a is an alias of each element in @b. I my pull request, I needed to build a hash aliasing array elements in needed to to it manually[3]. Is it possible to make: \my %h = \(@a) do a sensible thing? i.e. the hash values are alias to the corresponding array elements. Regards. Footnotes: [1] https://github.com/tobyink/p5-kavorka/pull/19 [2] https://github.com/tobyink/p5-kavorka/issues/18 [3] https://github.com/tobyink/p5-kavorka/pull/19/files#diff-2313f12b34a85c007c2af4e430e5b3cfR294
Subject: Re: [perl #122947] [EXPERIMENT] Aliasing via reference
Date: Fri, 16 Dec 2016 23:52:56 +0100
To: perl5-porters [...] perl.org
From: Aristotle Pagaltzis <pagaltzis [...] gmx.de>
Download (untitled) / with headers
text/plain 294b
* Daniel Dehennin via RT <perlbug-comment@perl.org> [2016-12-15 00:00]: Show quoted text
> Is it possible to make: > > \my %h = \(@a) > > do a sensible thing? > > i.e. the hash values are alias to the corresponding array elements.
Corresponding how? Where would the hash keys come from and in what order?
Subject: Re: [perl #122947] [EXPERIMENT] Aliasing via reference
Date: Sat, 17 Dec 2016 12:40:55 +0100
To: Father Chrysostomos via RT <perlbug-comment [...] perl.org>
From: demerphq <demerphq [...] gmail.com>
Download (untitled) / with headers
text/plain 842b
See Array::refelem

On 14 Dec 2016 23:53, "Daniel Dehennin via RT" <perlbug-comment@perl.org> wrote:
Show quoted text
Hello,

I recently play[1] with refaliasing to fix Kavorka on Perl >= 5.24[2].

As far as I understand in the documentation, with something like

    \my(@a) = \(@b);

each element in @a is an alias of each element in @b.

I my pull request, I needed to build a hash aliasing array elements in
needed to to it manually[3].

Is it possible to make:

    \my %h = \(@a)

do a sensible thing?

i.e. the hash values are alias to the corresponding array elements.

Regards.

Footnotes:
[1]  https://github.com/tobyink/p5-kavorka/pull/19

[2]  https://github.com/tobyink/p5-kavorka/issues/18

[3]  https://github.com/tobyink/p5-kavorka/pull/19/files#diff-2313f12b34a85c007c2af4e430e5b3cfR294


CC: "OtherRecipients of perl Ticket #122947": ;, perl5-porters [...] perl.org
Subject: Re: [perl #122947] [EXPERIMENT] Aliasing via reference
Date: Fri, 6 Jan 2017 13:09:17 +0100
To: Daniel Dehennin via RT <perlbug-comment [...] perl.org>
From: Abigail <abigail [...] abigail.be>
Download (untitled) / with headers
text/plain 753b
On Sun, Dec 11, 2016 at 03:17:41AM -0800, Daniel Dehennin via RT wrote: Show quoted text
> Hello, > > I recently play[1] with refaliasing to fix Kavorka on Perl >= 5.24[2]. > > As far as I understand in the documentation, with something like > > \my(@a) = \(@b); > > each element in @a is an alias of each element in @b. > > I my pull request, I needed to build a hash aliasing array elements in > needed to to it manually[3]. > > Is it possible to make: > > \my %h = \(@a) > > do a sensible thing? > > i.e. the hash values are alias to the corresponding array elements. >
As in: the values in the array with odd indices become aliases (values in the hash) and the values in the array with even indices become copies (keys in the hash)? Abigail


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org