From: deuteros <deuteros@xrs.net>
Subject: Re: Assigning a "subclass" instance to a "superclass" variable
Date: Fri, 6 Apr 2012 23:13:40 +0000 (UTC)
Date: 2012-04-06T23:13:40+00:00 [thread overview]
Message-ID: <jlntb4$pm8$1@dont-email.me> (raw)
In-Reply-To: m2ty0wh6n9.fsf@pushface.org
On Fri 06 Apr 2012 05:50:18p, Simon Wright <simon@pushface.org> wrote in
news:m2ty0wh6n9.fsf@pushface.org:
> with Statements;
> package Expressions is
> type Expression is new Statements.Statement with record
> ...
> end record;
> function Execute (Skip : Boolean; S : Expression) return Integer;
> end Expressions;
>
> or
>
> package Statements.Expressions is
> type Expression is new Statement with record
> ...
> end record;
> function Execute (Skip : Boolean; S : Expression) return Integer;
> end Statements.Expressions;
>
> The second form is good if the full declaration of Statement is in the
> private part of Statements, since child packages can see the private
> parts of their parents.
Okay, so would I need to put tokens and executedtokens in Expression's
record as well or would it somehow inherit them from Statements?
I want something like a constructor in my child classes:
function Create_Expression (tokens, executedtokens : Vector) return Expression is
E : Expression
begin
E.tokens := tokens;
E.executedtokens := executedtokens;
return E;
end Create_Expression;
Now if the Expression package must have its own tokens and executedtokens
I assume this would be the way to do it but if not then how would this
work?
next prev parent reply other threads:[~2012-04-06 23:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-06 20:49 Assigning a "subclass" instance to a "superclass" variable deuteros
2012-04-06 21:50 ` Simon Wright
2012-04-06 23:13 ` deuteros [this message]
2012-04-07 7:06 ` Simon Wright
2012-04-07 7:06 ` Dmitry A. Kazakov
2012-04-07 7:08 ` Niklas Holsti
2012-04-07 10:18 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox