comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: Generics - Difference between ADA and Modula--3
Date: Wed, 07 Feb 2001 14:52:12 GMT
Date: 2001-02-07T14:52:12+00:00	[thread overview]
Message-ID: <95rneo$eub$1@nnrp1.deja.com> (raw)
In-Reply-To: mailman.981529807.716.comp.lang.ada@ada.eu.org

In article <mailman.981529807.716.comp.lang.ada@ada.eu.org>,
  comp.lang.ada@ada.eu.org wrote:
> > I would have much preferred a rule that allowed arrays of classwide
> > objects, but handled them something like the ways arrays of variant
> > records are currently treated.
>
> Ted, with variant records, you know the maximum size, and this is what
> is allocated for arrays of unconstrained variant records.
> For tagged types, you do not know the maximum size.

At link time you could figure that out since by then all the sizes of
all the types in the class are known, but that is perhaps too much work.
It'd be nice for the users if it could be done, but I'd think it would
require a custom linker for Ada programs. Since a lot of compilers rely
on common C linkers, I don't think such a solution would be deemed
acceptable by vendors.

However, that's for *constained* variant record (sub)types. (Perhaps I'm
using the wrong terminology.) What I was talking about was that for an
unconstrained variant record type, the declaration of an object must
have some kind of initializer specifying the variants being used (and
thus the size). Thereafter the variant can't be changed, although the
other fields can. That would still not get rid of every instance where
pointers are needed, as you'd have to be able to live with an array
where you are unable to change the components too drasticly.

Right now, variant record types and other "indefinite subtypes" may not
be used in arrays. However, let's say for a moment that they could be.
Such an array would have to have the following restrictions:

   o  Any objects declared of this array's type would have to have an
initializer so that all the array elements would be constrained.
   o  Assignments to elements in the array could not change the variants.

If we then extend this hypothetical array rule to tagged types, you can
just replace "variants" with "tag" in the above, and things should work out.

Now that I type this out though, the argument is starting to look quite
familiar. If I remember right, the problem with it is that making array
elements take up different physical sizes blows simple array indexing
out of the water. You'd have to index into it by walking through the
array one element at a time. Since this is the same work as traversing a
linked-list, you might as well just use a linked-list for this purpose
and be done with it.

Clearly better minds than mine have already been over this. If a
solution was easy enough that *I* could figure it out, we wouldn't be in
this pickle in the first place. :-)

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com
http://www.deja.com/



       reply	other threads:[~2001-02-07 14:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.981529807.716.comp.lang.ada@ada.eu.org>
2001-02-07 14:52 ` Ted Dennison [this message]
2001-01-30  4:48 Generics - Difference between ADA and Modula--3 John Baltomoire
2001-01-30 16:04 ` Mark Carroll
2001-02-02 18:35   ` David Starner
2001-02-05 20:51     ` Mark Carroll
2001-02-05 21:46       ` David Starner
2001-02-06  0:36         ` Jeffrey Carter
2001-02-05 22:46       ` Pat Rogers
     [not found]       ` <95p1p7$3s9$1@nnrp1.deja.com>
     [not found]         ` <slrn98049v.155.lutz@taranis.iks-jena.de>
2001-02-07 13:10           ` John English
2001-02-12 20:38       ` Mark Carroll
2001-02-05 23:12     ` Mark Lundquist
2001-02-05 23:50       ` David Starner
2001-02-06  0:03       ` David Starner
replies disabled

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