[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fun-O Basic Edition Compiler
In article <3C3234FC.7060508@quiotix.com>, Jeffrey Siegal
<jbs@quiotix.com> wrote:
> Bruce Hoult wrote:
>
> > In article <3C321156.1020709@quiotix.com>, Jeffrey Siegal
> > <jbs@quiotix.com> wrote:
> >
> >
> >>>You can always declare a particular value to have a more restricted
> >>>type.
> >>>
> >>Is there such a type in Dylan?
> >>
> >
> > Millions of 'em...
> >
> > limited(<integer>, from: 20, to: 4123)
>
> 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").
Detecting addition overflow of unsigned numbers is easy and efficient:
if (a+b) < a then you have overflow. For signed 2s-complement it's a
little more work, but OK, such as: "r=a+b; if ((r^a)^(r^b) < 0)
overflow()".
How can you do it for multiplication, other than by dividing afterwards
and comparing, or pre-classifying the operands?
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.
-- Bruce