From: Jean-Pierre Rosen on 9 Feb 2010 06:23 Hibou57 (Yannick Duch�ne) a �crit : > On 9 f�v, 10:11, Jean-Pierre Rosen <ro...(a)adalog.fr> wrote: >>> clause... the use clause is particularly evil here. > With package named Parent, containing a type named Parent, having a > use clause on Parent brings into a context where the name Package can > be both resolved as a package or as a type. > > The use clause is clearly involved here, as one the way to get ride of > this error is to remove the use clause. The other way being to rename > either the type either the package. > > May be I was wrong to say the use clause is particularly evil there : > I should have said � the use clause is particularly vicious there > � (due to its vicious side effect in such a kind of context). > I don't see anything vicious. You have to understand that the use clause is "weak", it never goes against normal visibility. You have a package named Parent which is directly visible, a type named Parent which is use-visible. In this case, the use clause politely gives the way to direct visibility. The evil/vicious/whatever is in having nested entities with the same name. -- --------------------------------------------------------- J-P. Rosen (rosen(a)adalog.fr) Visit Adalog's web site at http://www.adalog.fr
From: Robert A Duff on 9 Feb 2010 10:08 Bryan <brobinson.eng(a)gmail.com> writes: > package Parent is > type Parent is abstract tagged private; Using the same name for the package and the type will lead to confusion. A common convention is to use a plural for the package, and a singular for the main type in that package. "Parent" is a fairly meaningless name, but in a real program you'd have something like: package Widgets is type Widget is ... - Bob
From: Bryan on 9 Feb 2010 18:39 Thanks everyone for correcting my code. Changing the package name cleared up the errors. I should have looked harder at the package names from the book. I'll probably be back with more questions when I'm stuck again. Thanks for the help.
From: Randy Brukardt on 9 Feb 2010 21:47 "Jean-Pierre Rosen" <rosen(a)adalog.fr> wrote in message news:tjgrkh.el7.ln(a)hunter.axlog.fr... > Hibou57 (Yannick Duch�ne) a �crit : >> On 9 f�v, 10:11, Jean-Pierre Rosen <ro...(a)adalog.fr> wrote: >>>> clause... the use clause is particularly evil here. >> With package named Parent, containing a type named Parent, having a >> use clause on Parent brings into a context where the name Package can >> be both resolved as a package or as a type. >> >> The use clause is clearly involved here, as one the way to get ride of >> this error is to remove the use clause. The other way being to rename >> either the type either the package. >> >> May be I was wrong to say the use clause is particularly evil there : >> I should have said � the use clause is particularly vicious there >> � (due to its vicious side effect in such a kind of context). >> > I don't see anything vicious. You have to understand that the use clause > is "weak", it never goes against normal visibility. You have a package > named Parent which is directly visible, a type named Parent which is > use-visible. In this case, the use clause politely gives the way to > direct visibility. > > The evil/vicious/whatever is in having nested entities with the same name. I suspect that the "evil" thing here is that the programmer is expecting the use clause to have some effect, but it does not. And that is confusing (although it is the confusing naming that is the real problem, not the presence or absence of the use clause). Randy.
First
|
Prev
|
Pages: 1 2 Prev: GNAT.Expect on Windows, without terminal window Next: GCC 4.5 mingw-w64 |