comp.lang.ada
 help / color / mirror / Atom feed
* Scope of identifiers
@ 1996-04-17  0:00 Kevin F. Quinn
  1996-04-18  0:00 ` Jon S Anthony
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin F. Quinn @ 1996-04-17  0:00 UTC (permalink / raw)


Is there a way (I've looked and can't find one) of informing an Ada compiler that
a prefix is a package?  The following (contrived) code example illustrates:

  package Pong is
    procedure Neutralise;
  end Pong;

  with Pong;
  procedure OdourControl is
    type Smells is (Pong, Whiff);
    Smell : Smells;
  begin
    Smell := Pong;
    Pong.Neutralise;
  end OdourControl;

Now; as a human, I can identify immediately that "Pong.Neutralise" is intended to mean
"call procedure Neutralise from package Pong".  Unfortunately, the above code generates
a semantic error, as when parsing the "Pong.Neutralise", the meaning of Pong is taken
to be that of the enumeration literal, which is eclipsing the package Pong.

If it were the other way round, where the package name were in the more immediate
scope, one could write Smells'Pong to get at the enumeration literal.  Is there
anything similar which can explicitly tell the compiler that an identifier is a
package?

As an aside, are there any situations where an enumeration literal makes any sense
at all as an lvalue?  I can't think of any...

Cheers,
Kev.




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

* Re: Scope of identifiers
  1996-04-17  0:00 Scope of identifiers Kevin F. Quinn
@ 1996-04-18  0:00 ` Jon S Anthony
  0 siblings, 0 replies; 2+ messages in thread
From: Jon S Anthony @ 1996-04-18  0:00 UTC (permalink / raw)


In article <3174F2AF.1C4@banana.demon.co.uk> "Kevin F. Quinn" <kevq@banana.demon.co.uk> writes:

> Is there a way (I've looked and can't find one) of informing an Ada compiler that
> a prefix is a package?  The following (contrived) code example illustrates:
> 
>   package Pong is
>     procedure Neutralise;
>   end Pong;
> 
>   with Pong;
>   procedure OdourControl is
      package Pong_Pkg renames Pong;  <----
>     type Smells is (Pong, Whiff);
>     Smell : Smells;
>   begin
>     Smell := Pong;
>     Pong_Pkg.Neutralise;            <----
>   end OdourControl;

Rename the thing before you occlude it with the new definition so
you can use it later..

>  As an aside, are there any situations where an enumeration literal
> makes any sense at all as an lvalue?  I can't think of any...

Neither can I...

/Jon
-- 
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178

617.484.3383
jsa@organon.com





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

end of thread, other threads:[~1996-04-18  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-17  0:00 Scope of identifiers Kevin F. Quinn
1996-04-18  0:00 ` Jon S Anthony

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