On Thu, Sep 22, 2005 at 08:20:42 +1000, Damian Conway wrote: > Ingo Blechschmidt asked: > > > my $pair = (a => 42); > > say ~$pair; # "a\t42"? "a\t42\n"? "a 42"? > > Not yet specified but I believe it should be "42" (i.e. stringifies to value). > > Note that S02 does specify that pairs *interpolate* to key-tab-val-newline, > so you can still get "a\t42\n" by writing "$pair" instead.
Can we override &circumfix:<" ">? Seriously though, this is too much dichotomy between correctness and ease of use. A pair is not it's value, it is a pair, and should be consistently handled as such when e.g. stringifying. The reasons for this claim are: * Coercion to a string creates something interpolatable. Introducing another type or context or metaphor for string handling is counter intuitive and surprising. * We have powerful facilities for interpolation and stringification that don't have to be hidden behind operator overloading: "this is my special pair: $pair"; "otherwise: $pair.key -> $pair.value"; my multi &prefix:<~> (Pair $p) { "key: $p.key, value: $key.value"; } "not like the first interpolation: $pair"; $pair.as(...); These examples are flexible, explicit and stable in their behavior. They are good enough as they are and don't need to be "improved" by adding flexibility in something that is almost a special case. * This adds complexity without much benefit. It heaps up the core with a special case that people will have to look out for later, and it hinders the usability of higher order functions by making it harder for them to accept the stringiciation operator, for instance. This lessens Perl 6 stability and cleanliness into something resembling Perl 5 with more builtin data types and operations -- () Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418 perl hacker & /\ kung foo master: /me whallops greyface with a fnord: neeyah!!!!!!!
pgpy8MCliC3EM.pgp
Description: PGP signature