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. I'd like to throw a _str and _num suffix on them, so we have:


  eq_str
  lt_num
  cmp_str

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). Cross-type comparisons without PMCs won't be allowed, 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)

Unqualified eq/cmp/lt are OK for two PMC operations, and call the underlying unqualified comparison check, but I'd bet that's rarely used.

A Perl compiler will probably emit only the <op>_str or <op>_int
variants. The opcode replacement inside imcc can emit an error or
warning, if the opcodes have the wrong operands, and can replace the
opcodes with the plain variants without _str or _int suffix, if there is
no matching opcode.

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)
--
Dan


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to