On Mon, 8 Dec 2003 11:35:59 -0500, Dan Sugalski <[EMAIL PROTECTED]> wrote:
>At 12:15 PM +0100 12/7/03, Leopold Toetsch wrote: >>Pete Lomax <[EMAIL PROTECTED]> wrote: >>> ... only to find there are no such equivalents for ne, gt, and ge. >> >>I've added these missing ops now. *But* there are a lot more missing: > >Yeah, we need all the comparison operators for PMCs in both numeric >and string versions. This needs quite careful thought. >I'd like to throw a _str and _num suffix on >them, so we have: > > eq_str > lt_num > cmp_str I disagree/don't see the point, pls read on. > >and so on. I think, at this point, that I'm OK with restricting the >eq/lt/whatever unqualified versions to same-type comparisons--i.e.: > > eq I5, 13 > lt S5, "Foo" > >and have them do the obvious thing (numeric or string comparison). AFIAK, this happens quite reasonably now. >Cross-type comparisons without PMCs won't be allowed, Agreed, that's been my (short-term) experience. >so if you want this: > > lt S5, 12 > >you'll need to either get the integer contents of S5 or turn 12 into >a string, so it's a two-op sequence. Not too onerous. (int/float >mixes are still OK, they're obvious) Yes, 1) get length of string, 2) compare integers. (or whatever) > >Unqualified eq/cmp/lt are OK for two PMC operations, I'm not convinced at all here. PMC comparison ops, afaict, are based solely on the pmc instance/address Here's a snippet to play with: $P1 = new Array $P1 = 2 $P1[0] = 1 $P1[1] = 1 $P2 = new Array $P2 = 2 $P2[0] = 1 $P2[1] = 1 # eq $P1, $P2, _L3 eq "fred", "fred", _L3 print "error \"fred\"!=\"fred\"" _L3: Is $P1=$P2? > and call the >underlying unqualified comparison check, but I'd bet that's rarely >used. Well, that's what I'm doing: eq_i_i_*, eq_n_n_*, and eq_s_s_*, I'm using directly; the rest are going though a check/cast types routine. >Odds are most compilers will go for the explicit string or numeric >comparisons, or MMD on type to figure out which to use, but we can >leave that to the compiler writers. (Enough people have been burned >with the whole "my numbers sorted weird" issue to explicitly specify >numeric or string comparisons pretty much everywhere)