IIRC this hash behavior is deliberate so that hashes can be accumulated. Also, your proposed behavior would require an object hash, not a standard hash; (%a => %b) would necessarily stringify %a.
On Thu, Apr 6, 2017 at 4:46 PM, Aleks-Daniel Jakimenko-Aleksejev < perl6-bugs-follo...@perl.org> wrote: > # New Ticket Created by Aleks-Daniel Jakimenko-Aleksejev > # Please include the string: [perl #131111] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=131111 > > > > Code: > my @a = <a b c>; > my @b = <1 2 3>; > my @c = @a, @b; > say @c > > Result: > [[a b c] [1 2 3]] > > > So with arrays, nothing is flattened and you get an array with two > elements. Makes sense. > > And if we want to get a different behavior, we can use slip: > > Code: > my @a = <a b c>; > my @b = <1 2 3>; > my @c = |@a, |@b; > say @c > > Result: > [a b c 1 2 3] > > > Everything is fine so far. Now, let's try the same thing with hashes: > > Code: > my %a = <a b c d>; > my %b = <1 2 3 4>; > my %c = %a, %b; > say %c > > Result: > {1 => 2, 3 => 4, a => b, c => d} > > > To me that looks like an inconsistency, I would have expected it to create > a hash with one pair (%a => %b). In fact, both 「%c = %a, %b」 and 「%c = |%a, > |%b」 work exactly the same! > > The idea of %a => %b may seem weird, but it really isn't if you consider > object hashes (my %c{Hash} = %a => %b; or even my %c{Hash} = $%a, $%b) > > Another thing to note is that this array behavior was changed during the > GLR, but hashes remained the same. Perhaps that was an oversight. > -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net