On Mon, 2002-09-09 at 21:42, Clinton A. Pierce wrote: > >Should these conversions be individual instructions (e.g. "uint2string") > >or should there be a single-target "pack" analog in the PBC? > > I like the idea of having a single pack/unpack instruction, with some kind > of argument mechanism to determine exactly how to pack. I don't know of an > analogue in other CPU instruction sets (except maybe BCD ops in 8086), as > they're typically not interested in something as high minded as some of > this is.
Yeah, I'm leaning that way too. > And while we're wishing, I'm certain I wouldn't want it as platform > dependant as Perl's pack() is. I'd like to be able to easily determine if > I'm working with native ints or some other kind of int. If I want to I'd > like to pack my ints to 16, 32, or 64 bits on a whim. Use BCD and BER and > any other strange encoding schemes I want. That makes sense. While parrot's "pack" (I think something like "convert" might make more sense) will be used to write the Perl version, there's no reason for it to have the same constraints. In fact, perhaps Perl's could use an overhaul while we're at it, but that's a subject for p6l.... > Something else to throw into the discussion is whether we want to use a > template (at the PBC level) as pack does or not. My initial gut reaction > is no, because then we'd wind up with things like: > > pack S0, "ccxxcc", P0 # where P0 is a PerlArray or something As you correctly point out, you don't want a string here. This isn't aimed at being convenient to program in, but a good target for back-end code generation (at least one level of back-end, there might be more). So if we have something like: pack S0, foo, bar What are foo and bar. I think foo is some sort of enumeration for the various pack operations (just and integer parameter in the PBC) and bar's type is dependent on foo. So, for example: set S0, "" pack S1, PackSignedC8, P0[0] concat S0, S1 pack S1, PackSignedC8, P0[1] concat S0, S1 set I2, 0 pack S1, PackUnsignedC8, P0[2] concat S0, S1 concat S0, S1 pack S1, PackSignedC8, P0[3] concat S0, S1 pack S1, PackSignedC8, P0[4] concat S0, S1 Woudl be roughly what you described above, assuming the enumerated arguments PackUnsignedC8 and PackSignedC8. > And I want a pony, too. Darn, where's that "me too" key on these new-fangled laptop keyboards?! :) > Then again, I drool at the prospect of doing an sprintf in PASM... I'm writing it in Perl6 now (all except for the low-level type conversion) and it's a pain. There are so darn many special cases! -- Aaron Sherman <[EMAIL PROTECTED]> http://www.ajs.com/~ajs