comp.lang.ada
 help / color / mirror / Atom feed
From: Eryndlia Mavourneen <eryndlia@gmail.com>
Subject: Re: Ada202X : alternate syntax for ranged scalars
Date: Fri, 26 Apr 2013 05:26:49 -0700 (PDT)
Date: 2013-04-26T05:26:49-07:00	[thread overview]
Message-ID: <3861a3cd-2513-4871-9062-2f2a53eb106b@googlegroups.com> (raw)
In-Reply-To: <09e7fbc6-ea75-4660-8ece-25c5b096afd5@googlegroups.com>

On Friday, April 26, 2013 5:10:01 AM UTC-5, Martin wrote:
> The default scalar declarations are 'closed ranges', i.e. include both upper and lower in the valid range.
> 
> Sometimes we would like to specify a 'half open range', e.g. values of degree from 0.0 up to BUT NOT INCLUDING 360.0.
> 
> I'm floating (pun intended) an alternative syntax for specify such ranges (or 'intervals')...
> 
> type Degree is digits 15 range [0.0, 360.0); -- includes 0 but not 360
> 
> The current 'closed ranges' would be:
> type Degree is digits 15 range [0.0, 360.0]; -- includes 0 and 360
> 
> Fully open range, i.e. not include 0.0 or 360.0:
> 
> type Degree is digits 15 range (0.0, 360.0); -- includes neither 0 nor 360
> 
> A 'reverse' half open range, i.e. not include 0.0 but including 360.0:
> 
> Usual rules would apply to the simple expression between the brackets.
> 
> Any thoughts?
> -- Martin

I agree with Peter.  A syntax more closely allied with current syntax might be:

  type Degree is digits 15 range 0.0 .. not 360.0; -- includes 0 but not 360
 
The current 'closed ranges' would be the same as now:
  type Degree is digits 15 range 0.0 .. 360.0; -- includes 0 and 360
 
Fully open range, i.e. not include 0.0 or 360.0:
 
 type Degree is digits 15 range not 0.0 .. not 360.0; -- includes neither 0 nor 360

That said, we must assume that floating point values get translated *exactly*; that is, 360.0 does not get translated to a machine type of 359.999999... or 360.0111111...

-- Eryndlia F. Mavourneen



  parent reply	other threads:[~2013-04-26 12:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-26 10:10 Ada202X : alternate syntax for ranged scalars Martin
2013-04-26 10:35 ` Peter C. Chapin
2013-04-26 12:26 ` Eryndlia Mavourneen [this message]
2013-05-02  2:11   ` Randy Brukardt
2013-05-02 13:29     ` Eryndlia Mavourneen
2013-04-26 12:53 ` AdaMagica
2013-04-26 14:46   ` Shark8
2013-04-28  2:11   ` Stephen Leake
2013-04-26 16:55 ` Jeffrey Carter
2013-05-02 23:05 ` Jerry
2013-05-14 22:30 ` Martin
replies disabled

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