From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,87cefb21a3c43af8 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.glorb.com!news.cs.univ-paris8.fr!proxad.net!cleanfeed2-b.proxad.net!nnrp1-1.free.fr!not-for-mail Message-Id: <44b94a19$0$23905$626a54ce@news.free.fr> From: Yves Bailly Subject: Re: Trouble with overriding and class-wide parameters Newsgroups: comp.lang.ada Date: Sat, 15 Jul 2006 22:03:31 +0200 References: <44b91f16$0$27041$626a54ce@news.free.fr> User-Agent: KNode/0.10.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit Organization: Guest of ProXad - France NNTP-Posting-Date: 15 Jul 2006 22:03:37 MEST NNTP-Posting-Host: 81.56.171.53 X-Trace: 1152993817 nnrp1-1.free.fr 23905 81.56.171.53:34861 X-Complaints-To: abuse@proxad.net Xref: g2news2.google.com comp.lang.ada:5712 Date: 2006-07-15T22:03:37+02:00 List-Id: 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 | //\ \_/ | | \_/`