comp.lang.ada
 help / color / mirror / Atom feed
From: "Jean-Pierre Rosen" <rosen@adalog.fr>
Subject: Re: Modular integers
Date: Wed, 29 Oct 2003 11:39:42 +0100
Date: 2003-10-29T11:39:42+01:00	[thread overview]
Message-ID: <246onb.pnn.ln@skymaster> (raw)
In-Reply-To: bnntu1$13vcju$1@ID-175126.news.uni-berlin.de

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 937 bytes --]


>"Vinzent 'Gadget' Hoefler" <ada.rocks@jlfencey.com> a �crit dans le message de
news:bnntu1$13vcju$1@ID->175126.news.uni-berlin.de...
>As you can see, the behaviour of the subtype is absolutely correct,
>although it might not be intuitive. I mean, adding 1 raises a
>constraint error while adding 2 (or even more, try it) doesn't.
>
>So what we get here is a modular type with range constraints. *That's*
>interesting... :-)

The key to understanding this behaviour is that an expression is computed in its base type (not the expected subtype), and then
converted to the expected subtype (which can raise Constraint_Error).

Therefore, Constraint_Error is raised if the final value of the expression is incompatible with the constraint,
but not during intermediate computations.

-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





  reply	other threads:[~2003-10-29 10:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-28 12:13 Modular integers Lars
2003-10-28 12:28 ` David C. Hoos
2003-10-28 12:48   ` Lars
2003-10-28 14:13     ` Vinzent 'Gadget' Hoefler
2003-10-28 16:55       ` Lars
2003-10-28 18:50         ` David C. Hoos
2003-10-28 20:46           ` Lars
2003-10-29  8:30         ` Vinzent 'Gadget' Hoefler
2003-10-29 10:39           ` Jean-Pierre Rosen [this message]
2003-10-29 12:16             ` Vinzent 'Gadget' Hoefler
2003-10-29  1:51 ` Raising exceptions (was: Modular integers) Jeffrey Carter
2003-10-29  3:02   ` Raising exceptions Hyman Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox