Re: The Sort Problem: a definitive ruling

2004-02-21 Thread Gordon Henriksen
On Friday, February 20, 2004, at 05:48 , Damian Conway wrote: Joe Gottman asked: How do you decide whether a key-extractor block returns number? Do you look at the signature, or do you simply evaluate the result of the key-extractor for each element in the unsorted list? For example,

Re: The Sort Problem: a definitive ruling

2004-02-20 Thread Smylers
Luke Palmer writes: Uri Guttman writes: DC == Damian Conway [EMAIL PROTECTED] writes: DC @sorted = sort {-M}={$^b cmp $^a} @unsorted; but there is no comma before @unsorted. is that correct? Yes. Commas may be ommitted on either side of a block when used as an argument.

Re: The Sort Problem: a definitive ruling

2004-02-20 Thread Luke Palmer
Smylers writes: Luke Palmer writes: Uri Guttman writes: DC == Damian Conway [EMAIL PROTECTED] writes: DC @sorted = sort {-M}={$^b cmp $^a} @unsorted; but there is no comma before @unsorted. is that correct? Yes. Commas may be ommitted on either side of a block

Re: The Sort Problem: a definitive ruling

2004-02-20 Thread Smylers
Joe Gottman writes: sort {$_.key} (1= 'a', 10 = 'b', 2 ='c'); There is nothing in the signature of the key-extractor to suggest that all the keys are numbers, but as it turns out they all are. Are they? I'd been presuming that pair keys would always be strings (as for hashes in Perl

Re: The Sort Problem: a definitive ruling

2004-02-20 Thread Luke Palmer
Smylers writes: Joe Gottman writes: sort {$_.key} (1= 'a', 10 = 'b', 2 ='c'); There is nothing in the signature of the key-extractor to suggest that all the keys are numbers, but as it turns out they all are. Are they? I'd been presuming that pair keys would always be strings

Re: The Sort Problem: a definitive ruling

2004-02-20 Thread Smylers
Luke Palmer writes: After this statement: $x = '345'; C$x is a number. Oh. I'd been assuming that quote marks indicated strings, and that, while a string containing only digits could obviously be treated as a number (as in Perl 5), it wouldn't be one without being provoked. I

Re: The Sort Problem: a definitive ruling

2004-02-20 Thread Dan Sugalski
At 2:49 PM -0700 2/20/04, Luke Palmer wrote: After this statement: $x = '345'; C$x is a number. No, it isn't. It's a string. Or, rather, it's a PerlScalar. I should hope it would be treated as one during multimethod dispatch. I should certainly hope *not*. If so, it's a bug. We ought to go

Re: The Sort Problem: a definitive ruling

2004-02-20 Thread Luke Palmer
Smylers writes: Luke Palmer writes: After this statement: $x = '345'; C$x is a number. Oh. I'd been assuming that quote marks indicated strings, and that, while a string containing only digits could obviously be treated as a number (as in Perl 5), it wouldn't be one

Re: The Sort Problem: a definitive ruling

2004-02-20 Thread Damian Conway
Uri wondered: DC No. C infix:= is the name of the binary C = operator. so how is that allowed there without a block? A Code object in a scalar context yields a Code reference. Damian

Re: The Sort Problem: a definitive ruling

2004-02-20 Thread Damian Conway
Smylers wrote: sort {$_.key} (1= 'a', 10 = 'b', 2 ='c'); There is nothing in the signature of the key-extractor to suggest that all the keys are numbers, but as it turns out they all are. Are they? I'd been presuming that pair keys would always be strings Nope. and that the C =

Re: The Sort Problem: a definitive ruling

2004-02-20 Thread Damian Conway
Luke wrote: I think you're forgetting what language you're talking about. Those are numbers. After this statement: $x = '345'; C$x is a number. I don't think so. C$x is, of course, a variable. And what it contains after that statement will depend on whether the variable is explicitly

Re: The Sort Problem: a definitive ruling

2004-02-20 Thread Damian Conway
Smylers wrote: Oh. I'd been assuming that quote marks indicated strings, and that, while a string containing only digits could obviously be treated as a number (as in Perl 5), it wouldn't be one without being provoked. Correct. What about: $x = '0345'; Is that a number? Nope. A string

The Sort Problem: a definitive ruling

2004-02-19 Thread Damian Conway
The design team discussed The Sort Problem during yesterday's teleconference. Here is Larry's decision: final, definitive, and unalterable (well...for this week at least ;-) -cut-cut-cut-cut-cut-cut Csort in Perl6 is a global multisub: multi

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Dave Whipp
Damian Conway [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] type KeyExtractor ::= Code(Any) returns Any; # Modtimewise numerically ascending... @sorted = sort {-M} @unsorted; One thing I've been trying to figure out reading this: what is the signature of prefix:-M

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Luke Palmer
Dave Whipp writes: Damian Conway [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] type KeyExtractor ::= Code(Any) returns Any; # Modtimewise numerically ascending... @sorted = sort {-M} @unsorted; One thing I've been trying to figure out reading this: what is

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Uri Guttman
DC == Damian Conway [EMAIL PROTECTED] writes: DC Once again the Iron Designer rises to the supreme challenge of DC the Mailinglist Stadium and expresses the true spirit of Perl DC 6!!! and the challenge for next week is slicing squid with noodles! (or cutting down the mightiest tree in

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Damian Conway
Dave Whipp wondered: @sorted = sort {-M} @unsorted; One thing I've been trying to figure out reading this: what is the signature of prefix:-M ? i.e. how does it tell the outer block that it (the outer-block) needs a parameter? It doesn't. As A6 explained:

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Uri Guttman
DC == Damian Conway [EMAIL PROTECTED] writes: DC # Stringifically ascending... DC @sorted = sort @unsorted; DC or with a single two-argument block/closure (to sort by whatever the DC specified comparator is): DC # Numerically ascending... DC @sorted = sort {$^a

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Luke Palmer
Uri Guttman writes: DC == Damian Conway [EMAIL PROTECTED] writes: DC # Modtimewise numerically ascending... DC @sorted = sort {-M $^a = -M $^b} @unsorted; DC # Fuzz-ifically... DC sub fuzzy_cmp($x, $y) returns Int; DC @sorted = sort fuzzy_cmp, @unsorted;

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Luke Palmer
Luke Palmer writes: Yes. Commas may be ommitted on either side of a block when used as an argument. I would argue that they only be omitted on the right side, so that this is unambiguous: if some_function { ... } { ... } Which might be parsed as either: if

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Joe Gottman
- Original Message - From: Damian Conway [EMAIL PROTECTED] To: Perl 6 Language [EMAIL PROTECTED] Sent: Thursday, February 19, 2004 8:29 PM Subject: [perl] The Sort Problem: a definitive ruling Csort in Perl6 is a global multisub: multi sub *sort(Criterion @by: [EMAIL PROTECTED

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Damian Conway
Uri checked: DC @sorted = sort {$^a = $^b} @unsorted; so because that has 2 placeholders, it is will match this signature: type Comparator ::= Code(Any, Any) returns Int; Correct. i have to remember that placeholders are really implied args to a code block and not just in the

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Uri Guttman
DC == Damian Conway [EMAIL PROTECTED] writes: DC No. But this will work: DC sort infix:= @unsorted my brane hertz!! so that declares (creates?) an infix op as a code block? and since = is known to take 2 args it is parsed (or multidispatched) as a comparator block for sort? amazing how

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Uri Guttman
JG == Joe Gottman [EMAIL PROTECTED] writes: JGHow do you decide whether a key-extractor block returns number? Do you JG look at the signature, or do you simply evaluate the result of the JG key-extractor for each element in the unsorted list? For example, what is JG the result of

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Damian Conway
Uri bemoaned: DC sort infix:= @unsorted my brane hertz!! so that declares (creates?) an infix op as a code block? No. C infix:= is the name of the binary C = operator. amazing how you and luke both came up with the exact same answer. Great minds... etc. ;-) p6 syntax like that is

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Larry Wall
On Fri, Feb 20, 2004 at 02:47:55PM +1100, Damian Conway wrote: : Yep. Inside the body of Csort you'd access them as: : : $by.trait{descending} : $by.trait{insensitive} : : (unless Larry's changed the trait accessor syntax since last I looked). Well, if traits are just compile-time

Re: The Sort Problem: a definitive ruling

2004-02-19 Thread Uri Guttman
DC == Damian Conway [EMAIL PROTECTED] writes: DC Uri bemoaned: cause you agonize me head! DC sort infix:= @unsorted my brane hertz!! so that declares (creates?) an infix op as a code block? DC No. C infix:= is the name of the binary C = operator. so how is that allowed there