in reply to Exegesis 6 - Named binding
Simply because a pair has the same key value as one of the variables on the left side, it is assigned to that?I believe this is so we have behaviour orthogonal to that of named sub/method/etc parameters. As you can pass named parameters into a sub and it will do the right thing e.g
So we don't need to maintain order of the arguments we pass in as perl6 will do the right thing and alias the arguments to correct positions in the parameter list. Now when we do named binding it's pretty much the same thing, but without the sub call e.gsub func(Int $this, Str $that) { ... } func(279544, "a string"); ## or with named parameters func(that => 'thing you do', this => 0xdeadbeef);
Also notice that both the parameter list and the named binding alias their arguments as well as putting the arguments in the right place.($this, $that) := ( 279544, 'a string' ); ## or with named parameters ($this, $that) := (that => 'thing you do', this => 0xdeadbeef);
Then simply because of my naming of the variables I assign to, I would get the reverse result?If you're performing a simple assign, then yes, the reversing of the variables that are being to assigned to will get the reverse data (same as perl5). But of course if you bind instead and the return is a list of pairs then it should DTRT e.g
Now regardless of the order of the LHS, the values should be bound correctly as the flattening of %herd produces a list of pairs.sub &part(Selector $is_sheep, *@data) { ## body here return *%herd; } ($goat, $sheep) = part Animal::Cat, @animals;
makes no sence to me either, unless a colon is missing as inIndeed, because without the binding colon you don't get the named binding behaviour. I'll speculate that it'll empty out %details and then assign it whatever is on the RHS.
HTH
_________
broquaint
Disclaimer: IANAP6DG (I Am Not A Perl6 Design Guru ;)
In Section
Seekers of Perl Wisdom