comp.lang.ada
 help / color / mirror / Atom feed
* Preferred method for bringing in operators
@ 2001-07-03 15:16 Marin David Condic
  2001-07-03 17:49 ` Stephen Leake
  0 siblings, 1 reply; 6+ messages in thread
From: Marin David Condic @ 2001-07-03 15:16 UTC (permalink / 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/






^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-07-05 14:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2001-07-03 20:21     ` Stephen Leake
2001-07-03 23:04     ` tmoran
2001-07-05 14:04       ` Marin David Condic

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