comp.lang.ada
 help / color / mirror / Atom feed
* Question: Extensible subobject?
@ 1995-01-20 22:02 Martin Ruckert
  1995-01-25 18:57 ` Tucker Taft
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Ruckert @ 1995-01-20 22:02 UTC (permalink / raw)


I don't know enough about Ada to find the best solution to the following
problem using Ada. I would be interested in a solution to include it in a
comparison of major object oriented languages. So, someone out there
might know the answer.

Problem:
An interactive application presents texts to the user in windows.
Most of the texts are read only (help, messages, menus). The base class
is RO_Text, it has methods to provide read access to the text.

A subclass of RO_Text is Edit_Text, which defines some additional
data fields to do a more complex storage management and it provides
additional methods to allow changes to the text (e.g. insert a
character).

The base class for windows is RO_Window, it specifies a field t to be a
pointer to an RO_Text and has methods to perform all the updating of 
the screen to make the text visible.

I want the class Edit_Window to be a subclass of RO_Window. Edit_Window needs
additional methods to service requests to change the text shown (e.g.
inserting a character). This new methods will update the screen and it
should forward the message to its text.

I can create an Edit_Text and store the pointer to it in the field t of the
Edit_Window. So the text subobject has methods to perform the changes, but
the type of t is a pointer to a RO_Text. Will it allow access to the
necessary methods of the Edit_Text?

If I use a type conversion on t it needs runtime overhead for checking.
Type conversions should be avoided if anyway?

I would rather in Edit_Window redefine the type of t to be 
a pointer to Edit_Text. This enables the compiler to check that my
assignments to t are correct and spares the type conversion and the test
associated with it later.

Is it possible ?? How to handle it best ??

Martin

Address: ruckert@mcs.newpaltz.edu






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

end of thread, other threads:[~1995-01-25 18:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-01-20 22:02 Question: Extensible subobject? Martin Ruckert
1995-01-25 18:57 ` Tucker Taft

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