"TSa (Thomas Sandlaß)" skribis 2005-05-25 13:53 (+0200): > >>%a = ( a => 1, b => 2, c => 3 ) # @a = (1,2,3) > >HASH = THREE PAIRS > I look at it as &infix:{'='}:( Hash, List of Pair : --> Ref of Hash ) > and then try to understand how it behaves. BTW, I'm neither sure > of the type of the second invocant parameter nor of the return type. > Even the position of the : is contestable.
If assigning a ref to a hash uses the hashref's elements, then the same is to be expected for an array. Because this behaviour is unwanted for arrays (because you then can't assign a single arrayref anymore without doubling the square brackets, communicating an entirely wrong thing), hashes have to concede as well, even though %a = $href may not make sense. > And +[1,2,3] seems to mean &prefix:<+>:(Ref of Array: --> Num) > while +(1,2,3) is &prefix:<+>:(List: --> Num). More interesting The + forces scalar Num context. So it can probably be written as something resembling sub &prefix:<+> (Num $foo) { $foo } Prefix + doesn't take a list. If you use comma in scalar context, an array reference is created. This makes +[] and +() practically equal, but that doesn't mean [] and () are always exchangeable, or even that they have anything to do with eachother. In +[], the [] make the arrayref, while in +(), the comma does that. If you have +() without comma, you don't have an arrayref, because () only groups. > are the &infix:<,> inside I recall having read something about , being "listfix", not infix. The same would be true for Y and | and & and ^. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html