comp.lang.ada
 help / color / mirror / Atom feed
* Re: Compiler complaint legal?
  2001-06-20 18:17 Compiler complaint legal? M. A. Alves
@ 2001-06-20 17:51 ` Ted Dennison
  2001-06-20 18:02   ` Jean-Pierre Rosen
  2001-06-20 21:33 ` Robert A Duff
  2001-06-21 23:40 ` Jeff Creem
  2 siblings, 1 reply; 5+ messages in thread
From: Ted Dennison @ 2001-06-20 17:51 UTC (permalink / raw)


In article <mailman.993057563.10765.comp.lang.ada@ada.eu.org>, M. A. Alves
says...
>
>Package O defines type O.  GNAT does not recognize the type here:
>
>with O; use O;
>procedure O_Test is
>  Object: O; -- HERE

I don't believe you can have packages and types with the same name in the same
scope. Under the circumstances, I'd want to keep the package name.

You should probably aviod naming things the same as their enclosing package. On
the other hand, this is yet another reason to aviod the use clause.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Compiler complaint legal?
  2001-06-20 17:51 ` Ted Dennison
@ 2001-06-20 18:02   ` Jean-Pierre Rosen
  0 siblings, 0 replies; 5+ messages in thread
From: Jean-Pierre Rosen @ 2001-06-20 18:02 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1233 bytes --]

"Ted Dennison" <dennison@telepath.com> a �crit dans le message news: Lo5Y6.2832$yp1.84754@www.newsranger.com...
> In article <mailman.993057563.10765.comp.lang.ada@ada.eu.org>, M. A. Alves
> says...
> >
> >Package O defines type O.  GNAT does not recognize the type here:
> >
> >with O; use O;
> >procedure O_Test is
> >  Object: O; -- HERE
>
> I don't believe you can have packages and types with the same name in the same
> scope. Under the circumstances, I'd want to keep the package name.
Yes you can. However, the main rule is that something is use-visible only if it does not conflict with a name that would be
otherwise visible.
Therefore, O designates the package (which is directly visible) and not the type (which is only use-visible).

> You should probably aviod naming things the same as their enclosing package.
Certainly

>On
> the other hand, this is yet another reason to aviod the use clause.
Certainly not. The use clause has no effect in that case: when there is any risk of ambiguity, it nicely steps back. The "O" is the
same if there were no use clause.

--
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Compiler complaint legal?
@ 2001-06-20 18:17 M. A. Alves
  2001-06-20 17:51 ` Ted Dennison
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: M. A. Alves @ 2001-06-20 18:17 UTC (permalink / raw)
  To: comp.lang.ada

Package O defines type O.  GNAT does not recognize the type here:

with O; use O;
procedure O_Test is
  Object: O; -- HERE
begin
  Create(Object);
end O_Test;

I have to spell it out for him (tested, other lines being equal):

  Object: O.O;

Academic question: is this a legal complaint from a (aledgedly) validated
compiler?

(GNAT says "subtype mark required in this context" which I find confusing
because one does not immediately realise that what he is missing is a
"subtype indication" but this is another story I think.)

Thanks,

-- 
   ,
 M A R I O   data miner, LIACC, room 221   tel 351+226078830, ext 121
 A M A D O   Rua Campo Alegre, 823         fax 351+226003654
 A L V E S   P-4150 PORTO, Portugal        mob 351+939354002




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Compiler complaint legal?
  2001-06-20 18:17 Compiler complaint legal? M. A. Alves
  2001-06-20 17:51 ` Ted Dennison
@ 2001-06-20 21:33 ` Robert A Duff
  2001-06-21 23:40 ` Jeff Creem
  2 siblings, 0 replies; 5+ messages in thread
From: Robert A Duff @ 2001-06-20 21:33 UTC (permalink / raw)


"M. A. Alves" <maa@liacc.up.pt> writes:

> Package O defines type O.  GNAT does not recognize the type here:
> 
> with O; use O;
> procedure O_Test is
>   Object: O; -- HERE

> Academic question: is this a legal complaint from a (aledgedly) validated
> compiler?

Yes.

Package O hides type O.

> (GNAT says "subtype mark required in this context" which I find confusing
> because one does not immediately realise that what he is missing is a
> "subtype indication" but this is another story I think.)

The compiler first looks for all the O's that are direcly visible.
There's only one -- the package (the type is hidden).
Then it considers whether this thing is legal in this context
-- it isn't, because the thing after the colon should be the name of a
subtype, not the name of a package.  That's why you get the "confusing"
error message.

The visibility rules are spelled out in excruciating detail in chapter 8
of the RM.  The particular case here is: use_clauses are considered
last.  If there's an O visible in some outer scope, it will hide any O
in a 'use'd package (assuming they're not overloadable, as is the case
here).  When you say "with O;" that makes it visible in an outer scope
(namely, the scope of Standard).

If you choose to give your packages and types the same name (which I
don't think is a very good idea), then you will not be able to refer to
the type by its simple name -- you'll have to say O.O.

My style (when I'm using use clauses) is to call the package by the
plural of the type name: package Lists contains type List, or package
Symbol_Tables contains type Symbol_Table.

Another style I've seen is to *always* call the type by a particular
name, (say, T) and always use dot-notation to refer to it: Lists.T,
Symbol_Tables.T.  Here, the name T doesn't give any useful information,
other than the fact that it's a type (or it's the "main" type exported
by that package).  The useful information is embodied in the package
name.  I've also seen "Object" used in place of "T".  I don't really
like that style...

- Bob



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Compiler complaint legal?
  2001-06-20 18:17 Compiler complaint legal? M. A. Alves
  2001-06-20 17:51 ` Ted Dennison
  2001-06-20 21:33 ` Robert A Duff
@ 2001-06-21 23:40 ` Jeff Creem
  2 siblings, 0 replies; 5+ messages in thread
From: Jeff Creem @ 2001-06-21 23:40 UTC (permalink / raw)


> Academic question: is this a legal complaint from a (aledgedly) validated
> compiler?
>


As everyone else here has pointed out the compiler is correct.
With Robert gone I will point out that unless you purchased the compiler
from ACT you do not have a validated compiler. You have a compiler
that is based on some way on source code that at some version and target was
validated - maybe.


Also validation does not mean the compiler is 100% correct. It just means it
passes the validation suite.






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-06-21 23:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-20 18:17 Compiler complaint legal? M. A. Alves
2001-06-20 17:51 ` Ted Dennison
2001-06-20 18:02   ` Jean-Pierre Rosen
2001-06-20 21:33 ` Robert A Duff
2001-06-21 23:40 ` Jeff Creem

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox