|Re: New Book: The School of Niklaus Wirth firstname.lastname@example.org (2000-11-16)|
|Re: New Book: The School of Niklaus Wirth email@example.com (2000-11-19)|
|Re: New Book: The School of Niklaus Wirth firstname.lastname@example.org (2000-11-22)|
|Re: types and subranges, was New Book: The School of Niklaus Wirth email@example.com (Joachim Durchholz) (2000-11-25)|
|From:||"Joachim Durchholz" <firstname.lastname@example.org>|
|Date:||25 Nov 2000 01:08:21 -0500|
|References:||00-11-120 00-11-136 00-11-145|
|Posted-Date:||25 Nov 2000 01:08:20 EST|
> Now you have to decide what to do with an expression like (-i)
> for a "subrange" like 0..100. To convert to a larger range,
> to wrap or to detect a range error ?...
The Ada solution is:
1) All intermediate results are of type universal_integer, which is
infinite-precision arithmetic (the compiler can infer how many bits of
precision are really needed, so this doesn't involve dynamic data
2) Run-time checks (and possibly an exception) whenever such a value is
assigned to an ordinary integer variable (or parameter).
I find this quite reasonable, though it does make the usual arithmetic
operators special (they accept universal_integer as parameters, so they
cannot be user-defined).
Return to the
Search the comp.compilers archives again.