From: Yves Bailly <kafka.fr@laposte.net>
Subject: Re: Trouble with overriding and class-wide parameters
Date: Sat, 15 Jul 2006 22:03:31 +0200
Date: 2006-07-15T22:03:37+02:00 [thread overview]
Message-ID: <44b94a19$0$23905$626a54ce@news.free.fr> (raw)
In-Reply-To: cQaug.838594$084.240400@attbi_s22
Jeffrey R. Carter wrote:
> Note that Sub_Type is not a subtype.
Yes I know ;-) a better name would have been "Derived_Type" I guess.
> Sub_Pkg defines 2 procedures named Setup:
>
> 1. Implicitly, from the primitive Setup for Some_Type, with "not null
> access Sub_Type" and "access Some_Type'Class". The implementation of
> this is identical to the implementation of Pkg.Setup.
>
> 2. Explicitly, "not null access Sub_Type" and "access Sub_Type'Class",
> since it's "not overriding".
OK, now it's clearer for me. I hadn't perceived the "implicitiness" of
such packages/types structures.
> I would expect this to be ambiguous, since it matches the profile for
> both of the Setup procedures. If I'm correct, this would be a compiler
> error.
Actually, if I replace "st.Setup(null)" by "Sub_Pkg.Setup(st'Access, null)"
then I received an error, telling me it's ambiguous... which seems
sensible to me now and matches your comments. Maybe it's a compiler bug if
the error does not arise when using dotted notation, I'll send a message
to GNAT developers.
> In the C/++ mind set, it's common to have visible pointers and pointer
> parameters all over the place. In the Ada mind set, access types,
> parameters, and values are avoided whenever possible, and hidden when
> not. This isolates memory management, making memory-management errors
> easier to find, and usually makes the package easier for the client to
> use. It's rare, in a well designed Ada system, to have access
> types/values/parameters in package specifications. There's probably a
> way to design your system to avoid having access parameters in the specs.
I understand this, several people already told this to me. So I guess
I'll review everything to hide pointers as much as possible. Thanks all
for your advices, though they imply more work than expected ;-)
> As an Ada beginner, you will probably find it valuable to avoid "use"
> clauses. This may seem like more work, but you will learn useful things
> that way. In this case, you have no need for Pkg at all, and so should
> not even "with" it
That's true, in fact it's just a remain of experiments.
> ; typing "Sub_Pkg." in the declaration of St is
> actually less work than typing " use Sub_Pkg;".
Well, I'm not really a truely beginner in Ada, however my experience is
back to Ada83... There's a huge gap between Ada83 and Ada2005, but with
all your nice helps I'm sure I'll succeed in learning.
Thanks a lot all again for your help.
--
(o< | Yves Bailly : http://kafka-fr.net | -o)
//\ | Linux Dijon : http://www.coagul.org | //\
\_/ | | \_/`
next prev parent reply other threads:[~2006-07-15 20:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-15 17:00 Trouble with overriding and class-wide parameters Yves Bailly
2006-07-15 18:00 ` Dmitry A. Kazakov
2006-07-15 18:20 ` Yves Bailly
2006-07-15 19:12 ` Dmitry A. Kazakov
2006-07-15 18:52 ` Jeffrey R. Carter
2006-07-15 20:03 ` Yves Bailly [this message]
2006-07-16 0:20 ` Jeffrey R. Carter
2006-07-16 10:00 ` Javier Miranda
2006-07-16 12:11 ` Ludovic Brenta
2006-07-16 13:36 ` Javier Miranda
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox