comp.lang.ada
 help / color / mirror / Atom feed
* Re: Reuseable Scientific Types Package
       [not found]       ` <396A373A.1B80329F@lmco.com>
@ 2000-07-12  0:00         ` David Kristola
  2000-07-12  0:00           ` Brian Rogoff
  0 siblings, 1 reply; 3+ messages in thread
From: David Kristola @ 2000-07-12  0:00 UTC (permalink / raw)


On Mon, 10 Jul 2000 13:51:06 -0700, Howard W. LUDWIG wrote
(in message <396A373A.1B80329F@lmco.com>):

> David Kristola wrote:
>> A third option...
>> 
>> I too needed types with units.  With a little bit of work, i created a
>> program to auto-generate a types package with appropriate operators for
>> all of the types needed (an extensive list, which caused the number of
>> operators to explode).

{snip}

> Bill Whitaker certainly realized this when he participated
> in revising IEEE-Std. 1226, a project that became known as
> P1446.  His work on the original 1226 used the Kristola
> approach, which he regarded as manageable at the time.
> By the time P1446 rolled around, it became clear to Bill
> that one could never set up enough types and operators,
> so he switched over to something closer to the Pat Rogers
> approach.  (Ref. the index page
> http://users.erols.com/whitaker/
> and see metric.sty that led to IEEE-Std.1226; as well as
> iss_418.htm and si_cmts.txt that describe the adjusted
> approach used in the update P1446, which never made it
> past the draft stage.)

I will take a look at the document, thanks!

I was not looking to make reusable software when i cam up
with the idea.  Reuse is not within our scope.  Our schedule
is very tight, and we are not being paid to produce a
reusable product.

I think the idea of having a code generator might be reusable.
A user could enter in the set of types she is interested in
and produce a types package with just those types.  Any
individual project is likely to be limited in the units that
are important.

{Snip}

>> type Unitless_Type is new Interfaces.IEEE_Float_32;
>> subtype Radians_Type is Unitless_Type;
>> --...
>> type Per_Seconds_Type is new Unitless_Type;
>> subtype Radians_Per_Seconds_Type is Per_Seconds_Type;
> 
> It is true that the radian is a dimensionless unit (meaning
> it has dimensions of 1, sometimes expressed in the non-reduced
> form m/m, based on its definition), but "per second" is
> certainly not "unitless", nor is "radians per second".
> Is the information given above simply incomplete and you
> are deriving all (including Meters_Type, etc.) of your unit
> types from "Unitless_Type", or am I missing something else?

I think you are missing something.  Per_Seconds_Type is a
*new* type based on Unitless_Type.  Any good compiler will
optimize away any machine code for a type convert from one
to the other, but you can't add them together without a
type convert.

{Snip}

>> I am also playing with some ideas for a possible language extension.
>> This is one area where more power could be added to the language.  Much
>> of the unit checking can be done at compile time.  How bad does something
>> like this look?
>> 
>> type Unitless_Type is digits 6 with (Meters, Kilograms, Seconds);
> 
> Don't forget the other 4 base units in SI (ampere, kelvin,
> mole, candela).  Also, there are people who, in spite of all
> the good reasons to use [only] SI, still use such abominations
> as feet and pounds; most throw in at least the multiples and
> submltiples of SI units such as kilometer and gram.  The best
> mechanism will allow for those as well.

I was just giving an example.  I would have used Klingon
units if i knew what they were.  The idea is to have a user
defined list of units that accompany the type.  I have not
spent as much time thinking about the idea as i would like.
It needs some more thought before i write up a description.
For instance, before this thread, i had not considered
fractional powers.



-- 
--djk, keeper of arcane lore & trivial fluff
Home: David95036 plus 1 at america on-line
Spam: goto.hades@welovespam.com





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Reuseable Scientific Types Package
  2000-07-12  0:00         ` Reuseable Scientific Types Package David Kristola
@ 2000-07-12  0:00           ` Brian Rogoff
  2000-07-13  0:00             ` David Kristola
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Rogoff @ 2000-07-12  0:00 UTC (permalink / raw)


On Wed, 12 Jul 2000, David Kristola wrote:
> On Mon, 10 Jul 2000 13:51:06 -0700, Howard W. LUDWIG wrote
> (in message <396A373A.1B80329F@lmco.com>):
> 
> > David Kristola wrote:
> >> A third option...
> >> 
> >> I too needed types with units.  With a little bit of work, i created a
> >> program to auto-generate a types package with appropriate operators for
> >> all of the types needed (an extensive list, which caused the number of
> >> operators to explode).
> 
> {snip}
> ... snip again ...
> 
> I think the idea of having a code generator might be reusable.
> A user could enter in the set of types she is interested in
> and produce a types package with just those types.  Any
> individual project is likely to be limited in the units that
> are important.

Actually, the idea of a code generator is extremely useful, but I thought 
macros were considered a non-no in the Ada community. A powerful macro 
system would allow you to do a lot more than just handle systems of
units. You might want to examine some other macro and preprocessing
systems, like those of Common Lisp, Scheme, Dylan, M5, and CamlP4. 

-- Brian





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Reuseable Scientific Types Package
  2000-07-12  0:00           ` Brian Rogoff
@ 2000-07-13  0:00             ` David Kristola
  0 siblings, 0 replies; 3+ messages in thread
From: David Kristola @ 2000-07-13  0:00 UTC (permalink / raw)


On Wed, 12 Jul 2000 8:13:24 -0700, Brian Rogoff wrote
(in message <Pine.BSF.4.21.0007120805010.4351-100000@shell5.ba.best.com>):

(i said)
>> I think the idea of having a code generator might be reusable.
>> A user could enter in the set of types she is interested in
>> and produce a types package with just those types.  Any
>> individual project is likely to be limited in the units that
>> are important.
> 
> Actually, the idea of a code generator is extremely useful, but I thought 
> macros were considered a non-no in the Ada community. A powerful macro 
> system would allow you to do a lot more than just handle systems of units. 
> You might want to examine some other macro and preprocessing systems, like 
> those of Common Lisp, Scheme, Dylan, M5, and CamlP4. 

Ada has no defined macro system, but there is nothing to stop someone from
using external macros.  I have used macros in Ada code under VADS, and i
know (but do not personally use) that macros are available under Rational
Apex.

The code generator i mentioned above could possibly be constructed using
macros, but the one i developed at work is not a macro, it is a program
created in Ada, and maintained in our CM structure.  If we need to add a
type to the list of supported types, we would modify the generator, check
in those modifications, run it, and check in the 8 source files it produces
(which are also under CM control).


-- 
--djk, keeper of arcane lore & trivial fluff
Home: David95036 plus 1 at america on-line
Spam: goto.hades@welovespam.com





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-07-13  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <3963A48E.6A2AF132@gbr.msd.ray.com>
     [not found] ` <JpR85.123$R31.66951@nnrp2.sbc.net>
     [not found]   ` <39646F40.A8277C4E@linuxchip.demon.co.uk>
     [not found]     ` <01HW.B58C5C88023DF64C05DE478C@news.pacbell.net>
     [not found]       ` <396A373A.1B80329F@lmco.com>
2000-07-12  0:00         ` Reuseable Scientific Types Package David Kristola
2000-07-12  0:00           ` Brian Rogoff
2000-07-13  0:00             ` David Kristola

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