On Apr 4, 9:16 am, Graham <graham.st...@[EMAIL PROTECTED]
> wrote:
> I haven't been using Ada for all that long, but I have been thinking
> that a kinder, gentler version would be nice in some cir***stances.
> Not necessarily *no* type-checking, but the ability to mix, say,
> integers, fixed-point types and floats in an equation without
> cluttering up the code with conversions.
If you'd like one, write one using a record with a variant part.
type Number_Type is ( Integer_Type, Fixed1_Type, Float1_Type ) ;
-- etc.
type Number is record
T : Number_Type ;
case T is
when Integer_Type =>
Integer_Value : Integer ;
when Fixed1_Type =>
Fixed1_Value : Fixed1 ;
when Float1_Type =>
Float1_Value : Float1 ;
end case ;
end record ;
Now, when you choose your floating and fixed point types and then also
write your arithmetic operations and conversions, you may realize why
there's no universal one of these that's appropriate for everybody.
I'm sure you can make one that's appropriate for you.
As for syntax, you'll have to use explicit constructor functions for
constants. Perhaps you'd like to declare it as "type N is ...".
Eric


|