From: Gautier write-only <gautier_niouzes@hotmail.com>
Subject: Re: Type of the target of an assignment shall not be abstract
Date: Tue, 16 Feb 2010 04:14:06 -0800 (PST)
Date: 2010-02-16T04:14:06-08:00 [thread overview]
Message-ID: <5ed98506-27b6-4428-a773-a36de6edb1ed@15g2000yqi.googlegroups.com> (raw)
In-Reply-To: bb14092c-3a1a-48fd-88de-69bf8b719ed6@g19g2000yqe.googlegroups.com
> Choosing between both tricks, I'd prefer Dmitry's.
> I'll give a clear name to the concrete-before-abstract type, like
> "Pre_Root", and try to have it private.
> Let's see how it turns out...
It turns out perfectly.
*** Spec, private part:
-- We have a concrete type as hidden ancestor of the
Excel_Out_Stream root
-- type. A variable of that type is initialized with default values
and
-- can help re-initialize a Excel_Out_Stream when re-used several
times.
-- See the Reset procedure in body.
--
type Excel_Out_Pre_Root_Type is tagged record
[the 14 components]
end record;
type Excel_Out_Stream is abstract new Excel_Out_Pre_Root_Type with
null record;
*** Body:
procedure Reset(
xl : in out Excel_Out_Stream'Class;
format : Excel_type:= Default_Excel_type
)
is
dummy_xl_with_defaults: Excel_Out_Pre_Root_Type;
begin
...
dummy_xl_with_defaults.format:= format;
Excel_Out_Pre_Root_Type(xl):= dummy_xl_with_defaults;
end Reset;
*** GNAT and ObjectAda are happy, I as well :-)
Philosophically, it seems reasonable that an abstract type should be
somewhat "limited" in its use (NB: I've put ""'s around the word
'limited' :-) )
______________________________________________________________
Gautier's Ada programming -- http://gautiersblog.blogspot.com/
next prev parent reply other threads:[~2010-02-16 12:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-14 14:20 Type of the target of an assignment shall not be abstract Gautier write-only
2010-02-14 17:57 ` Dmitry A. Kazakov
2010-02-15 17:05 ` Adam Beneschan
2010-02-15 19:00 ` Hibou57 (Yannick Duchêne)
2010-02-23 21:19 ` Robert A Duff
2010-02-16 0:59 ` Adam Beneschan
2010-02-16 10:03 ` Gautier write-only
2010-02-16 12:14 ` Gautier write-only [this message]
2010-02-16 16:12 ` Adam Beneschan
2010-02-28 17:00 ` Gautier write-only
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox