comp.lang.ada
 help / color / mirror / Atom feed
From: Ray Blaak <blaak@infomatch.com>
Subject: Re: package dependence question
Date: 2000/05/30
Date: 2000-05-30T00:00:00+00:00	[thread overview]
Message-ID: <uk8gb3hvg.fsf@infomatch.com> (raw)
In-Reply-To: wccog5o809g.fsf@world.std.com

Robert A Duff <bobduff@world.std.com> writes:
> One thing you can do is declare tagged type Node, and then "type
> Node_Ptr is access all Node'Class;".  Make types A, B, and C derive from
> Node.  Then B can have a component like "Parent: Node_Ptr;".  You lose
> type checking -- the parent of a B is always an A, but the code doesn't
> say so, except in a comment.

Put the Parent : Node_Ptr in the Node type. Full type checking can be achieved
by making the constructors for a B node require an A node as a parent
parameter (and in general, a arbitrary node's constructor has a signature in
terms of the required parent node). Safety by construction!

-- 
Cheers,                                        The Rhythm is around me,
                                               The Rhythm has control.
Ray Blaak                                      The Rhythm is inside me,
blaak@infomatch.com                            The Rhythm has my soul.




  reply	other threads:[~2000-05-30  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-29  0:00 package dependence question Carl Banks
2000-05-29  0:00 ` Robert Dewar
2000-05-29  0:00 ` Jeff Carter
2000-05-29  0:00   ` Ray Blaak
2000-05-29  0:00 ` Antonio Dur�n Dom�nguez
2000-06-03  0:00   ` Robert I. Eachus
2000-05-30  0:00 ` Robert A Duff
2000-05-30  0:00   ` Ray Blaak [this message]
2000-05-30  0:00   ` Brian Rogoff
replies disabled

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