[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fun-O Basic Edition Compiler
Bruce Hoult wrote:
>>Not exactly. What I was getting at would use the "natural" limits of a
>>machine integer (like the native <integer> but with overflow checking).
>>Is there a way of specifying that?
>>
>
> I don't know what FunctionalDeveloper does. We don't have such a type
> in Gwydion Dylan.
>
> More than that, I don't know how to efficiently implement one in
> portable ANSI C, otherwise I'd be happy to add one. Which would also
> allow us to make our bignum support a lot more efficient (it currently
> works on 16 bit "digits").
A first cut would be to implement it the exact same way as
limited(<integer>, from: -2^31, to: 2^31-1), but without
> How can you do it for multiplication, other than by dividing afterwards
> and comparing, or pre-classifying the operands?
Well, sometimes you can preclassify at compile time...
> OTOH, maybe it's time for Gwydion to have just a *little* assembler.
> That's not nice given that it runs on a number of different CPUs, but
> maybe it's not *too* bad: x86 and PPC will cover most people. SPARC and
> MIPS and HPPA and IA64 would probably get the rest.
What's wrong with a little assembler on systems you chose to support and
standard C elsewhere?
On systems with 32x32->64 multiplication, this becomes very easy. (I
think that's what you were getting at.)
By the way, I just looked in the DRM and <integer> is *not* defined to
wrap there. The overflow behavior is left implementation-defined. So
programs which rely on <integer> wrapping are non-portable. That
suggests some merit in a compile-time option to trap such things, and it
also suggests some merit in having a class which is defined to wrap and
one which is defined to trap, for when the programmer explicitly wants
one behavior or the other.