Re: What does a Pair numify to?

2008-12-16 Thread Larry Wall
On Mon, Dec 15, 2008 at 04:43:51PM -0700, David Green wrote: I can't really think of a great example where you'd want to numify a pair, but I would expect printing one to produce something like a = 23 (especially since that's what a one-element hash would print, right?). Nope, would

Re: What does a Pair numify to?

2008-12-16 Thread Jon Lang
On Mon, Dec 15, 2008 at 10:26 PM, Larry Wall la...@wall.org wrote: On Mon, Dec 15, 2008 at 04:43:51PM -0700, David Green wrote: I can't really think of a great example where you'd want to numify a pair, but I would expect printing one to produce something like a = 23 (especially since that's

Re: What does a Pair numify to?

2008-12-16 Thread TSa
HaloO, Moritz Lenz wrote: The counter example is if you want to print a pair: .say for %hash.pairs.sort: { .value }; In that case it would be nice to have the key appear in the stringification. I see no problem as long as say gets a pair as argument. Then it can print the key and value

Re: What does a Pair numify to?

2008-12-16 Thread Jon Lang
TSa wrote: I see no problem as long as say gets a pair as argument. Then it can print the key and value separated with a tab. More problematic are string concatenations of the form say the pair is: ~ (foo = $bar); which need to be written so that say sees the pair say the pair is: ,

Re: What does a Pair numify to?

2008-12-16 Thread Jon Lang
Moritz Lenz wrote: Off the top of my head, see S06 for the gory details: my $pair = a = 'b'; named(a = 'b'); named(:ab); named(|$pair); positional((a = 'b')); positional((:ab)); positional($pair); As you say: the gory details, emphasis on gory. But if that's the way of things, so be

Re: What does a Pair numify to?

2008-12-16 Thread Moritz Lenz
Jon Lang wrote: That's a good point. Is there an easy way to distinguish between passing a pair into a positional parameter vs. passing a value into a named parameter? Off the top of my head, see S06 for the gory details: my $pair = a = 'b'; named(a = 'b'); named(:ab); named(|$pair);

Re: What does a Pair numify to?

2008-12-15 Thread Larry Wall
On Thu, Dec 11, 2008 at 02:24:54PM +0100, TSa wrote: HaloO, Carl Mäsak wrote: Pugs and Elf currently numify a Pair object to 2, and Rakudo currently dies of despair. My guess is that the semantics of Pugs and Elf falls out naturally form a pair being treated as a list of two elements, or

Re: What does a Pair numify to?

2008-12-15 Thread mark . a . biggar
-- Original message -- From: Larry Wall la...@wall.org On Thu, Dec 11, 2008 at 02:24:54PM +0100, TSa wrote: My idea is to let a pair numify to whatever the value numifies to. Same thing with stringification. In general I think that a pair should hide its key

Re: What does a Pair numify to?

2008-12-15 Thread Uri Guttman
mab == mark a biggar mark.a.big...@comcast.net writes: mab -- Original message -- mab From: Larry Wall la...@wall.org On Thu, Dec 11, 2008 at 02:24:54PM +0100, TSa wrote: My idea is to let a pair numify to whatever the value numifies to. Same thing

Re: What does a Pair numify to?

2008-12-15 Thread Jon Lang
Mark Biggar wrote: The only use case I can think of is sorting a list of pairs; should it default to sort by key or value? But this isn't a case of numifying a Pair, or of stringifying it - or of coercing it at all. If you've got a list of Pairs, you use a sorting algorithm that's designed

Re: What does a Pair numify to?

2008-12-15 Thread David Green
On 2008-Dec-15, at 4:18 pm, Jon Lang wrote: If you've got a list of Pairs, you use a sorting algorithm that's designed for sorting Pairs (which probably sorts by key first, then uses the values to break ties). Agreed. If you've got a list that has a mixture of Pairs and non-Pairs, I

Re: What does a Pair numify to?

2008-12-15 Thread Moritz Lenz
Larry Wall wrote: On Thu, Dec 11, 2008 at 02:24:54PM +0100, TSa wrote: HaloO, Carl Mäsak wrote: Pugs and Elf currently numify a Pair object to 2, and Rakudo currently dies of despair. My guess is that the semantics of Pugs and Elf falls out naturally form a pair being treated as a list of

Re: What does a Pair numify to?

2008-12-15 Thread Moritz Lenz
mark.a.big...@comcast.net wrote: -- Original message -- From: Larry Wall la...@wall.org On Thu, Dec 11, 2008 at 02:24:54PM +0100, TSa wrote: My idea is to let a pair numify to whatever the value numifies to. Same thing with stringification. In general I think

What does a Pair numify to?

2008-12-11 Thread Carl Mäsak
Pugs and Elf currently numify a Pair object to 2, and Rakudo currently dies of despair. My guess is that the semantics of Pugs and Elf falls out naturally form a pair being treated as a list of two elements, or something. The question still deserves to be raised whether always-2 is a good

Re: What does a Pair numify to?

2008-12-11 Thread TSa
HaloO, Carl Mäsak wrote: Pugs and Elf currently numify a Pair object to 2, and Rakudo currently dies of despair. My guess is that the semantics of Pugs and Elf falls out naturally form a pair being treated as a list of two elements, or something. The question still deserves to be raised