Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EXPERIMENT] reference-like syntax for variable aliasing #14150

Open
p5pRT opened this issue Oct 11, 2014 · 42 comments
Open

[EXPERIMENT] reference-like syntax for variable aliasing #14150

p5pRT opened this issue Oct 11, 2014 · 42 comments
Labels
experiment ticket tracking an active experiment

Comments

@p5pRT
Copy link

p5pRT commented Oct 11, 2014

Migrated from rt.perl.org#122947 (status was 'open')

Searchable as RT122947$

@p5pRT
Copy link
Author

p5pRT commented Oct 11, 2014

From @cpansprout

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

@p5pRT
Copy link
Author

p5pRT commented Oct 11, 2014

From @jkeenan

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?

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Oct 11, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Oct 11, 2014

From @cpansprout

On Sat Oct 11 05​:10​:36 2014, jkeenan wrote​:

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

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From @rjbs

* Father Chrysostomos <perlbug-followup@​perl.org> [2014-10-11T02​:53​:37]

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

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From @leonerd

On Tue, 14 Oct 2014 08​:47​:15 -0400
Ricardo Signes <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. 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

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From @cpansprout

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.

Also, we have LVALUE refs. Is this feature
actually
related to that?

No.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From @leonerd

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

--
Paul "LeoNerd" Evans

leonerd@​leonerd.org.uk
http​://www.leonerd.org.uk/ | https://metacpan.org/author/PEVANS

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From @Tux

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=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/

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From @ikegami

On Tue, Oct 14, 2014 at 8​:56 AM, Paul "LeoNerd" Evans <
leonerd@​leonerd.org.uk> wrote​:

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.

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From @rjbs

* 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? 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

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From sog@msg.mx

On 10/14/2014 10​:06 AM, H.Merijn Brand wrote​:

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

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From @ikegami

On Tue, Oct 14, 2014 at 11​:06 AM, H.Merijn Brand <h.m.brand@​xs4all.nl>
wrote​:

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) );

B says no

If the assignment is optimized away, why is it slower? I'll try to look
into it tonight.

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From 2bfjdsla52kztwejndzdstsxl9athp@gmail.com

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"?

/Bo Lindbergh

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From @Leont

On Tue, Oct 14, 2014 at 5​:06 PM, H.Merijn Brand <h.m.brand@​xs4all.nl> wrote​:

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.

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

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From @ap

* Father Chrysostomos via RT <perlbug-followup@​perl.org> [2014-10-14 15​:50]​:

‘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/>

@p5pRT
Copy link
Author

p5pRT commented Oct 15, 2014

From @cpansprout

On Tue Oct 14 08​:07​:44 2014, hmbrand wrote​:

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'
...

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

@p5pRT
Copy link
Author

p5pRT commented Oct 15, 2014

From @cpansprout

On Tue Oct 14 08​:18​:57 2014, perl.p5p@​rjbs.manxome.org wrote​:

* 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.)

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

@p5pRT
Copy link
Author

p5pRT commented Oct 15, 2014

From @cpansprout

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.)

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2014

From @demerphq

On 15 October 2014 02​:38, Father Chrysostomos via RT <
perlbug-followup@​perl.org> wrote​:

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/"

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2014

From @kentfredric

On 15 October 2014 04​:06, H.Merijn Brand <h.m.brand@​xs4all.nl> wrote​:

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

--
Kent

*KENTNL* - https://metacpan.org/author/KENTNL

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2014

From @leonerd

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

--
Paul "LeoNerd" Evans

leonerd@​leonerd.org.uk
http​://www.leonerd.org.uk/ | https://metacpan.org/author/PEVANS

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2014

From @cpansprout

On Thu Oct 16 08​:10​:18 2014, leonerd@​leonerd.org.uk wrote​:

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

@p5pRT
Copy link
Author

p5pRT commented Oct 17, 2014

From @ap

* Father Chrysostomos via RT <perlbug-followup@​perl.org> [2014-10-17 00​:55]​:

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.

@p5pRT
Copy link
Author

p5pRT commented Oct 17, 2014

From @rjbs

* Father Chrysostomos via RT <perlbug-followup@​perl.org> [2014-10-16T18​:51​:17]

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

@p5pRT
Copy link
Author

p5pRT commented Oct 17, 2014

From @cpansprout

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.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Oct 17, 2014

From Eirik-Berg.Hanssen@allverden.no

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").

  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

@p5pRT
Copy link
Author

p5pRT commented Oct 17, 2014

From @cpansprout

On Fri Oct 17 10​:17​:19 2014, Eirik-Berg.Hanssen@​allverden.no wrote​:

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.

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​:

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

@p5pRT
Copy link
Author

p5pRT commented Oct 17, 2014

From @rjbs

* Father Chrysostomos via RT <perlbug-followup@​perl.org> [2014-10-17T15​:52​:59]

So how about refaliasing? (I.e., aliasing via reference.)

That sounds better than anything so far.

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

@p5pRT
Copy link
Author

p5pRT commented Oct 18, 2014

From @cpansprout

On Fri Oct 17 08​:13​:20 2014, perl.p5p@​rjbs.manxome.org wrote​:

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

@p5pRT
Copy link
Author

p5pRT commented Oct 18, 2014

From @rjbs

* 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!

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Oct 18, 2014

From @perhunter

On 10/18/2014 10​:35 AM, Ricardo Signes wrote​:

* 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

@p5pRT
Copy link
Author

p5pRT commented Sep 30, 2016

From @epa

Are the perl5-porters prepared to now formally 'accept' this experimental feature, so that it will become supported and non-experimental in 5.24?

@p5pRT
Copy link
Author

p5pRT commented Sep 30, 2016

From @epa

...er I mean 5.26

@p5pRT
Copy link
Author

p5pRT commented Sep 30, 2016

From @cpansprout

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 514e62e, then after that it could be accepted. I myself no longer have the tuits for the forseeable future.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Oct 15, 2016

From @xsawyerx

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 514e62e, 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?

@p5pRT
Copy link
Author

p5pRT commented Dec 5, 2016

From @cpansprout

On Sat, 15 Oct 2016 06​:28​:07 -0700, xsawyerx@​gmail.com wrote​:

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 514e62e,
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

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2016

From daniel.dehennin@baby-gnu.org

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] tobyink/p5-kavorka#19

[2] tobyink/p5-kavorka#18

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

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2016

From [Unknown Contact. See original ticket]

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] tobyink/p5-kavorka#19

[2] tobyink/p5-kavorka#18

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

@p5pRT
Copy link
Author

p5pRT commented Dec 16, 2016

From @ap

* Daniel Dehennin via RT <perlbug-comment@​perl.org> [2016-12-15 00​:00]​:

Is it possible to make​:

\\my %h = \\\(@&#8203;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?

@p5pRT
Copy link
Author

p5pRT commented Dec 17, 2016

From @demerphq

See Array​::refelem

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

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\(@&#8203;a\) = \\\(@&#8203;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 = \\\(@&#8203;a\)

do a sensible thing?

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

Regards.

Footnotes​:
[1] tobyink/p5-kavorka#19

[2] tobyink/p5-kavorka#18

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

@p5pRT
Copy link
Author

p5pRT commented Jan 6, 2017

From @Abigail

On Sun, Dec 11, 2016 at 03​:17​:41AM -0800, Daniel Dehennin via RT wrote​:

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\(@&#8203;a\) = \\\(@&#8203;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 = \\\(@&#8203;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

@rjbs rjbs added experiment ticket tracking an active experiment and removed type-meta Severity Low labels Apr 30, 2021
@rjbs rjbs changed the title [EXPERIMENT] Aliasing via reference [EXPERIMENT] reference-like syntax for variable aliasing Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experiment ticket tracking an active experiment
Projects
None yet
Development

No branches or pull requests

2 participants