On Mon, Nov 07, 2005 at 11:20:39PM +0200, Ilmari Vacklin wrote: : On Mon, Nov 07, 2005 at 12:05:30PM -0800, Larry Wall wrote: : > On Mon, Nov 07, 2005 at 11:53:26AM -0800, Larry Wall wrote: : > : Also, if we provide a way to return a pair instead of a value from a : > : hash (currently done with the new :%hash<key> syntax), : > : > Whoops, I forgot I changed that to %hash:<key> (and %hash:{'key'} too). : : Playing the devil's advocate; maybe that should be %hash.pairs<key>, or : %hash.pair:key? I don't like the : there - it's too small, and hidden : %between the larger syntactical elements.
Leaving aside the visibility argument, which is a valid complaint, %hash.pairs implies generation of a list of pairs which can't be subscripted except by treating it as a hash. Whether you put .pairs (or .kv) before or after the subscript, it ends up being a special case. So it seems to be more of an adverbial idea, but I thought %hash<key>:pair is rather ugly, and prone to having :pair eat up the following syntax. We could improve the visibility of the colon like this: %hash.:<key> or maybe even %hash :<key> On the other hand, the colon notation doesn't give us .kv. But it's probably not too bad to say %hash.:[EMAIL PROTECTED] in that case. I thought a bit about adverbial solutions like: %hash{:pair @slice} %hash{:kv @slice} but it is problematic to extend those to: %hash<:pair key> %hash<:kv key> And it seems to me that we very frequently will want to pass named arguments that take their names from the keys of the hash: blurp 1,2,3, %options:<foo bar baz> and I wanted to get the named-arg indicator as near as I could to the actual argument names without destroying the <> quoting. Larry