comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@adaos.worldonline.co.uk>
Subject: Re: Consider her way -- Re: Dimensionality Checking
Date: Thu, 13 Dec 2001 21:08:42 -0000
Date: 2001-12-13T21:08:42+00:00	[thread overview]
Message-ID: <9vb863$e8rbj$2@ID-25716.news.dfncis.de> (raw)
In-Reply-To: mailman.1008097622.26173.comp.lang.ada@ada.eu.org

"Alexandre E. Kopilovitch" <aek@vib.usr.pu.ru> wrote in message
news:mailman.1008097622.26173.comp.lang.ada@ada.eu.org...

> Recent discussion about the dimensions/unit analysis seems to me... well,
not
> directed by the spirit of the Ada language. As far as I understand, all
> participants of the discussion presume that if the dimensional/unit
analysis
> should be done for an Ada program then it must be performed entirely with
the
> facilities of Ada language itself. I think that that assumption is plain
wrong.
> ...

The reason for proposing a unit (or dimension) checking scheme as an
extension to the Ada language, is so that the portability and other benefits
of standardisation will then apply.

My reasons for associating a unit with a type rather than a subtype is to do
with explicit conversion between values of the same dimensionality but
different units.

In Ada, values of the same subtype can be used interchangeably in
expressions; the only place where the subtype matters is where a variable is
updated, in which case the new value is checked to ensure it is compatible
with the variable's subtype. This is a basic priciple in Ada, and I did't
want to change it.

With scalar values of different types, the only way to use a value, X1 say,
of one type, T1 say, in a place where another type, T2 say, is expected, is
with an explict conversion T2(X1). The converse conversion T1(X2) is always
possible, and a view conversion implies two conversions, one in each
direction. This fits perfectly with the conversion between two values of
different units (of the same dimensionality), which is assumed to be
achievable by multiplication by a certain factor: the conversion is always
bidirectional (the converse conversion is achieved by multiplication by the
inverse of the factor).

Hence, it works neatly to associate a unit with a type.

--
Best wishes,
Nick Roberts






  parent reply	other threads:[~2001-12-13 21:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-11 19:10 Consider her way -- Re: Dimensionality Checking Alexandre E. Kopilovitch
2001-12-11 22:45 ` Mark Lundquist
2001-12-13 21:08 ` Nick Roberts [this message]
2001-12-17 18:06 ` Superassemblers: was " Richard Riehle
  -- strict thread matches above, loose matches on Subject: below --
2001-12-13  0:09 Consider her way -- " Alexandre E. Kopilovitch
2001-12-13 17:13 ` Mark Lundquist
2001-12-14 14:13 Alexandre E. Kopilovitch
2001-12-14 16:07 ` Wes Groleau
2001-12-14 19:49 ` Mark Lundquist
2001-12-15  2:24 Alexandre E. Kopilovitch
2001-12-17 12:49 ` 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