From: Anh Vo <anhvofrcaus@gmail.com>
Cc: nma@12000.org
Subject: Re: GNAT and Dimension Checking
Date: Mon, 2 Jul 2012 13:42:04 -0700 (PDT)
Date: 2012-07-02T13:42:04-07:00 [thread overview]
Message-ID: <d88ae03b-b657-40b9-a17f-c00b87d73dac@googlegroups.com> (raw)
In-Reply-To: <3c38572a-c06c-4b58-9405-ece43483b3cd@googlegroups.com>
On Sunday, July 1, 2012 3:44:19 AM UTC-7, (unknown) wrote:
> This feature is rather limited though. For example one cannot do conversions. If you have to work with an "irregular" unit, you will have to do the conversion yourself e.g.
>
> with System.Dim.MKS; use System.Dim.Mks;
> with System.Dim.Mks_IO; use System.Dim.Mks_IO;
> with Text_IO; use Text_IO;
>
> procedure Free_Fall3 is
> subtype Acceleration is Mks_Type
> with Dimension => ("m/s^2", Meter => 1, Second => -2, others => 0);
> G : constant acceleration := 127137.6 * km/(hour ** 2) ;
> T : Time := 10.0/3600.0 * hour;
> Distance : length;
>
> begin
> Put ("Gravitational constant: ");
> Put (G, Aft => 2, Exp => 0); Put_Line ("");
> Put ("Time: ");
> Put (T, fore => 4, Aft => 4, Exp => 0); Put_Line ("");
> Distance := 0.5 * G * T ** 2;
> Put ("distance travelled in 10 seconds (or 10/3600 hour) of free fall ");
> Put (Distance, fore => 4, Aft => 4, Exp => 0);
> Put_Line ("");
> end Free_Fall3;
I may be off track here. That is I thought I understood aspect syntax until I browsed to the definition of System.Dim.Mks.Mks_Type type.
type Mks_Type is new Long_Long_Float
with
Dimension_System => (
(Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
(Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
(Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
(Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
(Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
(Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
(Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
Can anyone point me to the ARM 2012 paragraph(s) which supports this syntax in general. Thanks.
Anh Vo
next prev parent reply other threads:[~2012-07-02 20:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-01 5:53 GNAT and Dimension Checking AdaMagica
2012-07-01 6:25 ` Nasser M. Abbasi
2012-07-01 10:44 ` yogeshwarsing
2012-07-02 20:42 ` Anh Vo [this message]
2012-07-02 20:58 ` Adam Beneschan
2012-07-02 21:51 ` Anh Vo
2012-07-01 15:18 ` AdaMagica
2012-07-01 15:47 ` yogeshwarsing
2012-07-06 10:47 ` AdaMagica
2012-07-08 1:50 ` Robert A Duff
2012-07-08 10:33 ` AdaMagica
2012-07-08 11:37 ` Dmitry A. Kazakov
2012-07-08 14:13 ` AdaMagica
2012-07-08 18:47 ` Jacob Sparre Andersen
2012-07-09 11:06 ` AdaMagica
2012-07-09 8:20 ` Martin
2012-07-09 11:19 ` AdaMagica
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox