comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: Announce: Grace project site operational
Date: Fri, 17 May 2002 10:35:01 +0200
Date: 2002-05-17T10:35:01+02:00	[thread overview]
Message-ID: <ruc9eu092qt58m7ru0nrnbeig5c6sjo2b0@4ax.com> (raw)
In-Reply-To: 3CE40B8E.70102@mail.com

On Thu, 16 May 2002 15:42:06 -0400, Hyman Rosen <hyrosen@mail.com>
wrote:

>Dmitry A. Kazakov wrote:
>> In short, generics are macros.
>
>In exactly the same sense that FOR loops are GOTOs.

In which sense? For and goto are language constructs. Generics are
rather meta-language (preprocessor's language) constructs. The idea of
a generic is: let's substitute A for X and see if the compiler will
eat that. Macros substitute arbitrary strings. C++ templates
substitute arbitrary types. Ada is much better in that respect, but is
still bad. If you consider Ada generics from ADT point of view, i.e.
how actual paramters match formal ones, you will note that it is
strong typed, but has no user-defined types (of formal generic
parameters) at all. All types are built-in: (<>), range <>, digits <>,
etc. C++ templates are simply untyped, substitute'n'pray.

>> Generics are bad for units because they enforce dimensioned
> > values be of unrelated types.
>
>Why is that bad?

Because dimensioned values are not unrelated. Their types are
siblings, having a common supertype, and very often we need objects of
that supertype.

> > For instance, a discriminant-based variant:
>>    type Measure (SI : Unit := Unitless) is record
>>       Gain : Number;
>>    end record;
>
>In all Ada versions that anyone here has ever mentioned,
>this drags along a discriminant as part of the object,

Yes it is an unfortunate feature of Ada [C++ is not better], which
tries to treat subtypes as things having same representation. Once
language designers drop this IMO unnecessary limitation, they will
say, that an unconstrainted subtype of Measure shall keep the
discriminant, while a constrained one shall not. Same with tags,
class-wide objects have one, specific ones do not. End of story.

>making it bigger.

That's no problem, your macro expansions (:-)) will probably eat even
more. The real problem is that it is slower. My implementation of
measurement units is approximately 4 times slower as compared with
pure floating-point arithmetic. (:-()

>>    X := Y; -- Constraint_Error
>> 
>> A decent Ada compiler should give you warning at compile time.
>
>In the type-based version, it *must* fail at compile time.

Just set warnings = errors in your IDE.

>> How do you write a Put for dimensioned values? It shall be class-wide
>> = work on all unit [sub]types. Do you want to make it generic and
>> instantiate each time?
>
>Yes, I would make it generic and instantiate each time.

How big will be your application, if all possible subroutines dealing
with units will be instantiated?

>In C++, of course, the instantiation would be done for me.
>Here's what it would look like for a simple gram-centimeter-second
>system. All of the 'if' tests in the code below are static at
>compile time, so they will not consume any runtime.

It will consume memory at run time. Your system will be too big. You
will be unable to put the things into a library, because, well,
generics are macros. You will be unable to write some applications at
all. Consider a unit-aware calculator. How to implement it with
generics?

>> There is a roller dynamometer.
>
>Shrug. Yes, if you really have a system where everything is
>completely dynamic, then a type-based solution will be difficult
>or perhaps impossible to use. On the other hand, I'm guessing
>that most people's sensors stay put and measure one thing.

Yes, but a sensor is usually attached to the system via an A/D
converter, which are expensive. So customers routinely reuse their
converters by re-attaching different sensors to the system: today a
temperature sensor, tomorrow a pressure sensor, etc. But the main
problem is virtual instuments. Should we instantiate all of them for
all necessary units, the system would probably require a cluster of
supercomputers. (:-))

The moral of the story is that no real system uses 100% static or 100%
dynamic checks. It is 20/80 or 80/20 depending on the application.
Therefore an ultimative solution shall effectively support both.
Generics cannot help us in that, they are doomed to be static.

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



  reply	other threads:[~2002-05-17  8:35 UTC|newest]

Thread overview: 158+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-08  2:38 Announce: Grace project site operational Ted Dennison
2002-05-08  2:48 ` Larry Kilgallen
2002-05-08 12:46   ` Ted Dennison
2002-05-08 13:33     ` Marin David Condic
2002-05-09 19:54       ` Randy Brukardt
2002-05-09 20:22         ` Marin David Condic
2002-05-10 14:59           ` Ted Dennison
2002-05-10 18:54           ` Randy Brukardt
2002-05-10 14:17       ` Larry Hazel
2002-05-10 14:46         ` David C. Hoos
2002-05-10 15:38         ` Marin David Condic
2002-05-11 14:17           ` Preben Randhol
2002-05-11 16:58             ` martin.m.dowie
2002-05-11 18:55               ` William C. Brennan
2002-05-11 20:10               ` Preben Randhol
2002-05-12  8:53                 ` martin.m.dowie
2002-05-13 13:18               ` Marin David Condic
2002-05-13 13:07             ` Marin David Condic
2002-05-14 15:18               ` Ted Dennison
2002-05-14 15:45                 ` Marin David Condic
2002-05-15 19:56                   ` Hyman Rosen
2002-05-16 13:44                   ` Stephen Leake
2002-05-14 17:02                 ` Martin Dowie
2002-05-15 14:57                   ` Ted Dennison
2002-05-15 15:31                     ` Marin David Condic
2002-05-16 21:57                       ` tmoran
2002-05-17  1:55                       ` tmoran
2002-05-17 13:12                         ` Marin David Condic
2002-05-18  1:44                           ` tmoran
2002-05-15 15:54                     ` Martin Dowie
2002-05-15 17:33                       ` Larry Kilgallen
2002-05-15 17:04                         ` David C. Hoos
2002-05-15 22:59                     ` tmoran
2002-05-16 13:36                       ` Marin David Condic
2002-05-16 13:43                       ` Ted Dennison
2002-05-16 14:51                         ` Marin David Condic
2002-05-17 15:34                         ` Stephen Leake
2002-05-20 13:47                           ` Marin David Condic
2002-05-21 14:23                             ` Stephen Leake
2002-05-21 17:24                               ` Ted Dennison
2002-05-21 17:52                                 ` Marin David Condic
2002-05-22 16:20                                   ` Stephen Leake
2002-05-28  8:22                                     ` Martin Dowie
2002-05-22 16:16                                 ` Stephen Leake
2002-05-16 11:06                     ` John English
2002-05-16 13:52                       ` Stephen Leake
2002-05-16 16:40                       ` Hyman Rosen
2002-05-14 17:50                 ` tmoran
2002-05-14 18:07                   ` Preben Randhol
2002-05-14 18:12                     ` Preben Randhol
2002-05-14 18:52                       ` Hyman Rosen
2002-05-15  8:17                         ` Dmitry A. Kazakov
2002-05-15 18:30                           ` Hyman Rosen
2002-05-16  9:16                             ` Dmitry A. Kazakov
2002-05-16 19:42                               ` Hyman Rosen
2002-05-17  8:35                                 ` Dmitry A. Kazakov [this message]
2002-05-20 17:08                                   ` Hyman Rosen
2002-05-21  8:34                                     ` Dmitry A. Kazakov
2002-05-21 15:57                                       ` Hyman Rosen
2002-05-22  7:48                                         ` Dmitry A. Kazakov
2002-05-22 11:40                                   ` Georg Bauhaus
2002-05-22 15:05                                     ` Dmitry A. Kazakov
2002-05-22 16:14                                       ` Georg Bauhaus
2002-05-22 16:31                                       ` Hyman Rosen
2002-05-23 11:40                                         ` Dmitry A. Kazakov
2002-05-15  8:44                         ` Martin Dowie
2002-05-15 18:15                           ` Stephen Leake
2002-05-15 18:39                             ` Darren New
2002-05-15 19:34                               ` Hyman Rosen
2002-05-15 23:52                                 ` Darren New
2002-05-16  7:39                                   ` Hyman Rosen
2002-05-16 15:35                                     ` Darren New
2002-05-16 17:55                                       ` Brian Rogoff
2002-05-16 13:35                                   ` Stephen Leake
2002-05-16 15:50                                     ` Darren New
2002-05-16 16:28                                       ` Hyman Rosen
2002-05-17 15:14                                       ` Stephen Leake
2002-05-17 16:08                                         ` Darren New
2002-05-17 16:41                                           ` Fraser Wilson
2002-05-17 16:43                                           ` Stephen Leake
2002-05-17 16:24                                         ` Marin David Condic
2002-05-17 15:03                                     ` Fraser Wilson
2002-05-17 15:27                                       ` Stephen Leake
2002-05-17 16:20                                         ` Fraser Wilson
2002-05-17 16:46                                           ` Stephen Leake
2002-05-18  6:14                                         ` Simon Wright
2002-05-17 15:44                                       ` Mark Biggar
2002-05-17 16:09                                         ` Fraser Wilson
2002-05-17 16:48                                           ` Stephen Leake
2002-05-17 21:11                                           ` Mark Biggar
2002-05-21  8:45                                       ` Dmitry A. Kazakov
2002-05-15 19:24                             ` Hyman Rosen
2002-05-15 23:33                         ` tmoran
2002-05-16 13:48                           ` Stephen Leake
2002-05-16 14:39                             ` Martin Dowie
2002-05-14 19:10                       ` tmoran
2002-05-14 19:58                         ` Preben Randhol
2002-05-11 19:42           ` Jeffrey Carter
2002-05-11 20:16             ` Preben Randhol
2002-05-11 19:49           ` Jeffrey Carter
2002-05-13 15:44             ` Ted Dennison
2002-05-13 16:16               ` Marin David Condic
2002-05-13 17:10               ` Stephen Leake
2002-05-13 19:07                 ` Preben Randhol
2002-05-13 20:21                 ` Marin David Condic
2002-05-14 15:00                 ` Ted Dennison
2002-05-14 16:00                   ` Stephen Leake
2002-05-14 16:30                     ` Preben Randhol
2002-05-13 19:16               ` Jeffrey Carter
2002-05-13 19:19               ` Simon Wright
2002-05-11  1:23         ` Richard Riehle
2002-05-11 12:27           ` Marc A. Criley
2002-05-08 16:12     ` Hyman Rosen
2002-05-08 16:31       ` Larry Kilgallen
2002-05-08 17:16         ` Marin David Condic
2002-05-09  9:50           ` Larry Kilgallen
2002-05-09 13:32             ` Marin David Condic
2002-05-09 13:54             ` Ted Dennison
2002-05-09 14:23               ` Mário Amado Alves
2002-05-09 20:02                 ` Randy Brukardt
2002-05-09 20:44                   ` Marin David Condic
2002-05-10 13:06                     ` Hyman Rosen
2002-05-10 16:23                       ` Preben Randhol
2002-05-10 18:57                         ` Hyman Rosen
2002-05-10 18:58                     ` Randy Brukardt
2002-05-10  8:35                   ` Dmitry A. Kazakov
2002-05-10  9:12                     ` GRACE web site (was Announce: Grace project site operationa)l David C. Hoos, Sr.
2002-05-10 14:33                       ` Ted Dennison
2002-05-10 16:17                         ` Preben Randhol
2002-05-13 14:07                           ` Ted Dennison
2002-05-13 16:04                             ` Darren New
2002-05-10 19:00                     ` Announce: Grace project site operational Randy Brukardt
2002-05-13  8:10                       ` Dmitry A. Kazakov
2002-05-10 19:35                     ` Ted Dennison
2002-05-13  8:01                       ` Dmitry A. Kazakov
2002-05-10 10:25                   ` Mário Amado Alves
2002-05-09 20:53               ` Simon Wright
2002-05-10  8:29               ` Dmitry A. Kazakov
2002-05-14 15:03                 ` John English
2002-05-15  8:34                   ` Dmitry A. Kazakov
2002-05-15 10:38                     ` John English
2002-05-15 11:18                       ` Dmitry A. Kazakov
2002-05-15 18:10                         ` Stephen Leake
2002-05-09 14:03           ` Wes Groleau
2002-05-09 15:38             ` Marin David Condic
2002-05-11 18:10         ` William C. Brennan
2002-05-08 22:00       ` Ted Dennison
2002-05-09  5:39         ` Hyman Rosen
2002-05-09 14:21         ` Wes Groleau
2002-05-25 22:03           ` Robert I. Eachus
2002-05-08 14:32 ` Stephen Leake
2002-05-10 14:46   ` Ted Dennison
2002-05-10  7:47 ` fraser
2002-05-10 14:55   ` Ted Dennison
  -- strict thread matches above, loose matches on Subject: below --
2002-05-15  9:58 Grein, Christoph
2002-05-15 16:12 ` Ted Dennison
2002-05-15 11:32 Grein, Christoph
2002-05-15 13:41 ` 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