comp.lang.ada
 help / color / mirror / Atom feed
From: Wes Groleau <wesgroleau@despammed.com>
Subject: Re: Announce: The Ultimate SI Units Cracker
Date: Fri, 13 Sep 2002 10:41:42 -0500
Date: 2002-09-13T10:41:42-05:00	[thread overview]
Message-ID: <3D820736.180E7286@despammed.com> (raw)
In-Reply-To: mailman.1031893204.31270.comp.lang.ada@ada.eu.org


> > What I'm getting at is the ability to define a private type
> > so that it has all the attributes and operations of a numeric
> > type and can be use as a generic parameter to a numeric package.
> 
> That would be really cool, perhaps with some Ada0Y features...
> But then it's not clear what e.g. a generic should do with the non-numeric
> components. It could just ignore them. But then how should a function know what
> to return if the actual for the formal T is SI_Unit?
> 
> generic
>   type T is digits <>;
> function F (X, Y: T) return T;

This means that the generic body can expect T to have
all the operations that any floating point type has.
It can not expect it to have any operations that are
not common to all floating point types.

The function would have to return whatever the generic
actual is.  And it can only get that by operations that
are inherited or overridden from Float or that it defines
by using such operations.

MAYBE ....

type Clever is private digits 9;

private

   type Clever is ....

end;

Require the body to define ALL operations
that would be available for a true floating
point type.  I know this is difficult--that's
probably why Java chose to have its dichotomy
between primitive types that are actually numbers,
and object-oriented types which, no matter how hard
you try, you _can't_ treat completely as numbers.

Or can you?

If some Java files have

class myInteger extends Integer
{
   ....
}

and

   myInteger WeeksInYear = new myInteger ( 52 );
   myInteger DaysInWeek  = new myInteger (  7 );

does Java allow methods to be defined to support

     myInteger DaysInYear  = WeeksInYear * DaysInWeek + 1;

-- 
Wes Groleau
http://freepages.rootsweb.com/~wgroleau



  parent reply	other threads:[~2002-09-13 15:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-13  4:53 Announce: The Ultimate SI Units Cracker Grein, Christoph
2002-09-13 14:34 ` Ira Baxter
2002-09-13 20:50   ` Stephen Leake
2002-09-16 10:22   ` Fraser Wilson
2002-09-13 15:41 ` Wes Groleau [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-09-13  5:34 Grein, Christoph
2002-09-12 11:59 Grein, Christoph
2002-09-12 11:51 Grein, Christoph
2002-09-12  8:11 Grein, Christoph
2002-09-12 10:14 ` Preben Randhol
2002-09-12 10:50 ` Jeffrey Creem
2002-09-12 14:06 ` Wes Groleau
2002-09-12 17:06   ` Randy Brukardt
2002-09-13 15:20     ` Wes Groleau
2002-09-13 20:54       ` Randy Brukardt
2002-09-13 22:09   ` Dmitry A.Kazakov
2002-09-13 15:26     ` Wes Groleau
2002-09-15  6:21       ` Dmitry A.Kazakov
2002-09-15  0:24         ` Mark Biggar
2002-09-16  1:35           ` 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