comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com>
Subject: Re: Preferred method for bringing in operators
Date: Tue, 3 Jul 2001 15:04:42 -0400
Date: 2001-07-03T19:04:43+00:00	[thread overview]
Message-ID: <9ht50b$dk6$1@nh.pace.co.uk> (raw)
In-Reply-To: uith9nbra.fsf@gsfc.nasa.gov

Yeah. That generates some ideas at least. Out of all the possible
approaches, this is one of them! :-)

I'm dealing basically with a tagged record and working from the polymorophic
approach. Its not that I don't like generics - its just that in this case I
want to be able to keep extending the classes to have new features as the
need arises & generics tend to be less amenable to this. Besides, from
looking at your generic example, I can see what I dislike about the
approach - the need to build long lists of generic formal parameters and the
difficulty this implies for the end-user. It has its advantages in many
cases, but I'd like to avoid it if possible. Still, if all I want is to get
a user defined "<" operator, this isn't so bad. I'm just not sure that it is
the "Object Oriented Ada Way" - or at least a way that one won't regret as
one uses and extends the package.

On another matter: It looks like you're doing some things similar to things
I have attempted - deriving tagged types from Ada.Finalization.Controlled.
I'm using Gnat 3.13p and have had trouble mixing this with various stream
operations. (What would appear to be legal & workable when it *doesn't*
derive from Finalization ends up crashing when it *does* derive from
Finalization.) I'm wondering if you have experienced similar troubles and if
so did you find a workaround? Are there other Ada compilers on which this
may have worked properly?

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> wrote in message
news:uith9nbra.fsf@gsfc.nasa.gov...
> "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com> writes:
>
> > This is a question about style and preferences, rather than something
purely
> > technical. I just want to know what people prefer and if there are any
> > reasons to consider one style superior to another...
> >
> > Suppose you build a class to represent a container of some objects. The
> > objects are just stored and retrieved from the container in no
particular
> > order. Now you want to derive a child class from the container only in
this
> > case you want to store and retrieve the objects in sorted order. That
means
> > you have to somehow extend the class to bring in one or more comparison
> > operations for the object being stored. A variety of solutions exist:
> > <snip>
>
> You first need to decide if you are using a tagged type approach, or a
> generic approach. Since you said "class", I guess you are leaning
> towards tagged types, but then you talk about generics, so I'm
> not clear.
>
> For my answer to both approaches, see
> http://users.erols.com/leakstan/Stephe/Ada/sal.html
>
> Specifically, for the generic approach, sal-gen-alg.ads defines the
> notion of an algoirthm on a container, sal-gen-alg-find_linear.ads
> extends that to a 'find' alorgithm. Then
> sal-gen-alg-find_linear-sorted.ads extends that to a linear sorted
> list, and sal-gen-alg-find_binary.ads extends it to binary searching
> on a sorted container.
>
> For the tagged type approach, see sal-poly-alg.ads,
> sal-poly-alg-find_linear.ads. These are also generics, but the basic
> container is a tagged type.
>
> Hope this helps :).
>
> --
> -- Stephe





  reply	other threads:[~2001-07-03 19:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-03 15:16 Preferred method for bringing in operators Marin David Condic
2001-07-03 17:49 ` Stephen Leake
2001-07-03 19:04   ` Marin David Condic [this message]
2001-07-03 20:21     ` Stephen Leake
2001-07-03 23:04     ` tmoran
2001-07-05 14:04       ` Marin David Condic
replies disabled

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