gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] enumerated types and import rules


From: Iztok Kobal
Subject: Re: [Gm2] enumerated types and import rules
Date: Thu, 15 May 2003 21:54:56 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0


Gaius Mulley wrote:

>Hi,
>
>I have a question about the rules of importing enumerated types
>and types derived from enumerated types.
>Consider these modules:
>
>MODULE impf ;
>
>IMPORT impb ;
>
>CONST
>   start = impb.red ;
>   end   = impb.green ;
>
>VAR
>   a: ARRAY [start..end] OF CARDINAL ;
>   b: impb.C ;
>BEGIN
>END impf.
>
>-----------
>
>DEFINITION MODULE impb ;
>
>IMPORT impc ;
>
>TYPE
>   C = impc.C ;
>
>END impb.
>
>-----------
>
>DEFINITION MODULE impc ;
>
>TYPE
>   C = (red, blue, green) ;
>
>END impc.
>
>In module impf it seems clear that the variable declaration of, b, is
>legal. Is it also legal to access impb.red and impb.green?  Or should
>it have to import C from impc.
>

Why this question at all ? Of course impb.red === impc.red and no need
to explicit import C from impc. In later case impb.red === red;

>I can see advantages in both, allowing
>impb.red and also disallowing impb.red but which is correct? The
>answer must be the same if we complicate the question by repacing
>impb with:
>
>DEFINITION MODULE impb ;
>
>IMPORT impc ;
>
>TYPE
>   C = PROCEDURE () : impc.C ;
>

No complication at all. The M2 visibility rule says clearly that impb.C
has nothing to do with impc.C in this example.

Anyway, GPM2 compiles this one OK:

DEFINITION MODULE impa ;

IMPORT impb ;
IMPORT impc;

CONST
   start = impb.red ;
   end   = impb.green ;

TYPE
   arr = ARRAY [start..end] OF CARDINAL ;

   C = PROCEDURE () : impc.C ;

END impa.

All in all - following might be interesting reading:
http://research.microsoft.com/Users/luca/Papers/TypeSystems.A4.pdf

>
>END impb.
>
>I think :-)
>
>Gaius
>
>_______________________________________________
>gm2 mailing list
>address@hidden
>http://floppsie.comp.glam.ac.uk/mailman/listinfo/gm2
>
>.
>
>
>



--
Your favorite stores, helpful shopping tools and great gift ideas.
Experience the convenience of buying online with address@hidden
http://shopnow.netscape.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]