comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Range excluding 0.0
Date: Sat, 29 Aug 2009 15:28:25 -0400
Date: 2009-08-29T15:28:25-04:00	[thread overview]
Message-ID: <wcc1vmus9ly.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 1j57hiw.vmezw81qexbi6N%csampson@inetworld.net

csampson@inetworld.net (Charles H. Sampson) writes:

> vlc <just.another.spam.account@googlemail.com> wrote:
>> 
>> I would like to declare a subtype of Float which ranges from 0.0
>> (excluded) to Float'Last. Is there a way to exclude the 0.0 from the
>> range?
>
>      You've already got the answer you need, but your question brings up
> another that I've recently been puzzled about.  Why doesn't Ada allow
> all four flavors of ranges commonly used by mathematicians (and others):
> individually including or excluding the endpoints?

For that matter, why doesn't Ada allow arbitrary subsets?
For example, "an integer in the range -1_000_000 to 1_000_000,
except 0 is not allowed".  Or, "an integer for which Is_Good
returns True".

ARG is thinking about adding type invariants and/or user-defined
constraints, which could express such things.

>...I've been around Ada
> since close to the beginning and I don't recall that this was ever
> discussed.  At the same time, I have this vague memory that one of the
> candidate languages might have had it, but I can't remember which one it
> might have been.
>
>      This is not just theoretical musing.  I currently work in the world
> of compasses, so a range of the form [0.0 .. 360.0) is quite natural.
> (That notation is neither mathematical nor Ada.  I hope its meaning is
> clear.)

It's certainly not Ada, but why do you say it's not mathematical?
I find it ugly, but I've certainly seen in maths textbooks.
Ignoring the ugly syntax, the concept seems quite useful.

- Bob



  reply	other threads:[~2009-08-29 19:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-29 12:50 Range excluding 0.0 vlc
2009-08-29 13:12 ` Dmitry A. Kazakov
2009-08-29 13:46 ` John B. Matthews
2009-08-29 17:10   ` vlc
2009-08-29 17:47 ` Charles H. Sampson
2009-08-29 19:28   ` Robert A Duff [this message]
2009-08-30 18:34     ` Charles H. Sampson
2009-08-29 20:51   ` John B. Matthews
2009-08-30  7:34     ` Dmitry A. Kazakov
     [not found]       ` <7_KdnXzM3cepeAfXnZ2dnUVZ_vidnZ2d@earthlink.com>
2009-08-31  7:37         ` Dmitry A. Kazakov
2009-08-31 13:58           ` John B. Matthews
2009-08-31 18:49             ` Dmitry A. Kazakov
2009-09-01 18:10               ` Keith Thompson
     [not found]             ` <iradnblskszGlgHXnZ2dnUVZ_oSdnZ2d@earthlink.com>
2009-09-01  0:36               ` John B. Matthews
2009-08-30  7:38   ` Dmitry A. Kazakov
2009-08-30 18:34     ` Charles H. Sampson
2009-08-30 20:43       ` Dmitry A. Kazakov
replies disabled

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