Related articles |
---|
Re: New Book: The School of Niklaus Wirth gdemont@my-deja.com (2000-11-16) |
Re: New Book: The School of Niklaus Wirth vbdis@aol.com (2000-11-19) |
Re: New Book: The School of Niklaus Wirth gdemont@my-deja.com (2000-11-22) |
Re: types and subranges, was New Book: The School of Niklaus Wirth joachim_d@gmx.de (Joachim Durchholz) (2000-11-25) |
From: | "Joachim Durchholz" <joachim_d@gmx.de> |
Newsgroups: | comp.compilers |
Date: | 25 Nov 2000 01:08:21 -0500 |
Organization: | Compilers Central |
References: | 00-11-120 00-11-136 00-11-145 |
Keywords: | types |
Posted-Date: | 25 Nov 2000 01:08:20 EST |
<gdemont@my-deja.com> wrote:
>
> 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
structures).
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).
Regards,
Joachim
Return to the
comp.compilers page.
Search the
comp.compilers archives again.