comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com>
Subject: Preferred method for bringing in operators
Date: Tue, 3 Jul 2001 11:16:43 -0400
Date: 2001-07-03T15:16:43+00:00	[thread overview]
Message-ID: <9hsnkr$90q$1@nh.pace.co.uk> (raw)

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:

1) Make the child generic and bring in the comparison functions needed in
the generic parameter list. Some version of 'with function "<" (Left..." The
user then needs to create an instance of the child providing the operation
as a parameter.

2) Declare in the child package an abstract function to operate on the
stored objects and provide comparisons. The user then needs to create one
more derivation from the child package to provide the abstract operation.

3) Extend the class for the stored objects to have a "Ordered Object" that
has abstract functions for comparisons. Allow only objects of this class to
be put in the list. The user must extend the object class to provide the
functions. (May have problems with compatibility with the parent class -
type conflicts, etc.)

4) Do something to declare an access type to the function and expect the
user to provide the access value as part of the creation of the list. (Don't
really like this answer much. Where do the declarations go and how would
they look?)

There may be other ways of doing the feline-epidermal-removal, but these are
the ones I can think of. I'm curious about what others think would be the
best idiom for doing this?

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/






             reply	other threads:[~2001-07-03 15:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-03 15:16 Marin David Condic [this message]
2001-07-03 17:49 ` Preferred method for bringing in operators Stephen Leake
2001-07-03 19:04   ` Marin David Condic
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