-
Notifications
You must be signed in to change notification settings - Fork 559
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
Comments
From @cpansproutThe 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 |
From @jkeenanOn Fri Oct 10 23:53:37 2014, sprout wrote:
Would it be possible for you to first post the documentation you would provide for this feature? Thank you very much. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @cpansproutOn Sat Oct 11 05:10:36 2014, jkeenan wrote:
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 |
From @rjbs* Father Chrysostomos <perlbug-followup@perl.org> [2014-10-11T02:53:37]
This sort of seemed to come out of nowhere from my perspective. Or, rather, I In saying, "Could we, next time, first have a public announcement that it's I will now begin kicking this around, anyway, and hope to find it purely Since I haven't much played with it yet, I don't have much to say, except this: -- |
From @leonerdOn Tue, 14 Oct 2014 08:47:15 -0400
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 -- leonerd@leonerd.org.uk |
From @cpansproutOn Tue Oct 14 05:47:48 2014, perl.p5p@rjbs.manxome.org wrote:
‘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.
No. -- Father Chrysostomos |
From @leonerdOn Tue, 14 Oct 2014 08:47:15 -0400
The things we have that are called LVALUE are the lvalues returned by my $str = "Hello world"; -- leonerd@leonerd.org.uk |
From @TuxOn Tue, 14 Oct 2014 15:43:40 +0100, "Paul \"LeoNerd\" Evans"
is that (internally) different from using the 4-arg form (which I $ perl -wE'$_="Foo";substr $_,1,0,"x";say' B says no $ perl -MO=Concise -wE'$_="Foo";substr($_,1,0)="x";say' $ perl -MO=Concise -wE'$_="Foo";substr $_,1,0,"x";say' cmpthese (-3, { Rate arg3 arg4 -- |
From @ikegamiOn Tue, Oct 14, 2014 at 8:56 AM, Paul "LeoNerd" Evans <
Good point. It has nothing to do with modifying references as the name |
From @rjbs* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-14T09:45:31]
From the user's perspective, is there actually a reference involved in the left Why not just "aliasing"? The use of \ makes sense, and can (I think) be taught -- |
From sog@msg.mxOn 10/14/2014 10:06 AM, H.Merijn Brand wrote:
$ perl -E 'my $str = "Hello"; for(substr($str,1,1)) { say $_; $_="ee"; e sortiz |
From @ikegamiOn Tue, Oct 14, 2014 at 11:06 AM, H.Merijn Brand <h.m.brand@xs4all.nl>
Better examples: my $ref = \substr($str, 0, 5); or sub f { $_[0] = "Goodbye"; } B says no If the assignment is optimized away, why is it slower? I'll try to look |
From 2bfjdsla52kztwejndzdstsxl9athp@gmail.comQuoth Paul LeoNerd Evans:
Agreed. How about "lreferences" or "lrefs"? /Bo Lindbergh |
From @LeontOn Tue, Oct 14, 2014 at 5:06 PM, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:
They are not identical at all.
I agree we that in that specific (but probably common) case that could Leon |
From @ap* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-14 15:50]:
But wrong. This has been bugging me all day, because the same confusion References are values, whereas lvalue context is a syntactical property So, call the feature `refconsassign` maybe? I don’t know. Personally I’m inclined to go with Rik right now, call it `varaliasing`. Basically as long as people need to spell the name of the feature it And the experimental phase will hopefully be brief while the long term Regards, |
From @cpansproutOn Tue Oct 14 08:07:44 2014, hmbrand wrote:
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 |
From @cpansproutOn Tue Oct 14 08:18:57 2014, perl.p5p@rjbs.manxome.org wrote:
Assignment has a return value, so yes. (Hmm. What should (\$x=\$y)=\$z do? Currently it probably does not do what anyone expects.)
‘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 |
From @cpansproutOn Tue Oct 14 12:01:32 2014, 2bfjdsla52kztwejndzdstsxl9athp@gmail.com wrote:
I’ve been calling them lvrefs internally, if that matters. (C.f. the new lvref magic type, the lvref op, lvref.t.) -- Father Chrysostomos |
From @demerphqOn 15 October 2014 02:38, Father Chrysostomos via RT <
Personally I think calling this aliasing is the right thing. Yves -- |
From @kentfredricOn 15 October 2014 04:06, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:
What will really bake your noodle, put them both in void context instead of use Benchmark qw( :hireswallclock cmpthese ); cmpthese( arg3_void => sub { my $foo = "foo"; substr( $foo, 1, 0 ) = "x"; 1 }, Rate arg3 arg4_void arg4 arg3_void that lone '1' on the end makes a difference of 200% :D -- *KENTNL* - https://metacpan.org/author/KENTNL |
From @leonerdOn Thu, 16 Oct 2014 09:31:24 +0200
+1 -- leonerd@leonerd.org.uk |
From @cpansproutOn Thu Oct 16 08:10:18 2014, leonerd@leonerd.org.uk wrote:
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 |
From @ap* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-17 00:55]:
Hrm, good point. Maybe `bind` (taking a page from Chip)? Has the What bugs me about `aliasing` just by itself is that it could be |
From @rjbs* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-16T18:51:17]
That's fine with me. If you wanted something more specific than "aliasing", which I could I think I am happy to let you name the thing, as long as you don't name it that -- |
From @cpansproutOn Fri Oct 17 07:31:49 2014, aristotle wrote:
I can’t think of what else it could be referring to in the context of Perl programming. -- Father Chrysostomos |
From Eirik-Berg.Hanssen@allverden.noOn Fri, Oct 17, 2014 at 6:29 PM, Father Chrysostomos via RT
For(each) loop variable ("implicit alias for each item"), glob 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) Eirik |
From @cpansproutOn Fri Oct 17 10:17:19 2014, Eirik-Berg.Hanssen@allverden.no wrote:
Yes, what distinguishes this is the *means* of aliasing, though it is all ultimately the same thing underneath.
So how about refaliasing? (I.e., aliasing via reference.) Ricardo Signes wrote:
But for \@x ( @array_of_arrays ) has no assignment in it. -- Father Chrysostomos |
From @rjbs* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-10-17T15:52:59]
That sounds better than anything so far.
I stand corrected! -- |
From @cpansproutOn Fri Oct 17 08:13:20 2014, perl.p5p@rjbs.manxome.org wrote:
Very well. I have renamed it ‘parsnip’ in commit baabe3f. -- Father Chrysostomos |
From @perhunterOn 10/18/2014 10:35 AM, Ricardo Signes wrote:
if you had another branch with that, you could call it a parsnip in a <ducks> uri |
From @epaAre the perl5-porters prepared to now formally 'accept' this experimental feature, so that it will become supported and non-experimental in 5.24? |
From @epa...er I mean 5.26 |
From @cpansproutOn Fri Sep 30 09:03:55 2016, ed wrote:
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 |
From @xsawyerxOn 09/30/2016 09:35 PM, Father Chrysostomos via RT wrote:
Is there a specific ticket for that? |
From @cpansproutOn Sat, 15 Oct 2016 06:28:07 -0700, xsawyerx@gmail.com wrote:
There is now: #130263. -- Father Chrysostomos |
From daniel.dehennin@baby-gnu.orgHello, 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 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: [3] https://github.com/tobyink/p5-kavorka/pull/19/files#diff-2313f12b34a85c007c2af4e430e5b3cfR294 |
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 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: [3] https://github.com/tobyink/p5-kavorka/pull/19/files#diff-2313f12b34a85c007c2af4e430e5b3cfR294 |
From @ap* Daniel Dehennin via RT <perlbug-comment@perl.org> [2016-12-15 00:00]:
Corresponding how? Where would the hash keys come from and in what order? |
From @demerphqSee Array::refelem On 14 Dec 2016 23:53, "Daniel Dehennin via RT" <perlbug-comment@perl.org>
|
From @AbigailOn Sun, Dec 11, 2016 at 03:17:41AM -0800, Daniel Dehennin via RT wrote:
As in: the values in the array with odd indices become aliases (values Abigail |
Migrated from rt.perl.org#122947 (status was 'open')
Searchable as RT122947$
The text was updated successfully, but these errors were encountered: