Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!mit-eddie!bloom-beacon!deccrl!news.crl.dec.com!pa.dec.com!src.dec.com!gnelson From: gnelson (Greg Nelson) Newsgroups: comp.lang.modula3 Subject: Re: Twelve changes to Modula-3 Message-ID: <9012201741.AA05285@jumbo.pa.dec.com> Date: 20 Dec 90 17:40:00 GMT Lines: 74 In-Reply-To: Message of 19 Dec 1990 1808-PST (Wednesday) from stolfi (Jorge Stolfi) <9012200208.AA02239@jumbo.pa.dec.com> To: stolfi (Jorge Stolfi) Cc: m3 X-Folder-Carbon: sent Jorge Stolfi asks several questions about the twelve changes to Modula-3 described in my previous message. First he mentions: (*1*) TYPE A = OBJECT METHODS m() END; B = OBJECT METHODS p() := A.m END; and correctly infers that this makes B.m be NIL. (*2*) TYPE A <: OBJECT METHODS m() END; B = OBJECT METHODS p() := A.m END; This is legal; the value of B.m is the same as A.m, but this value is unknown in the scope. (*3*) TYPE A = OBJECT METHODS m() := M; p() := A.m END; This is an illegal recursion, since the occurrence of A is not "within a field or method type of the type constructor OBJECT", to quote from the language definition. Of course in this case the recursion is harmless, but in the very similar A = OBJECT METHODS m() := A.m END the recursion is nonsensical. (*4*) TYPE P = OBJECT METHODS m(); p() := A.m END; A <: P; This is legal (or not illegal) as it stands, but I don't see any way to write a complete revelation that will make it into a legal program. For example, if you completed it by REVEAL A = P BRANDED OBJECT END; then the expanded definition of P would contain an illegal occurrence of A. (I have altered Jorge's example by introducing the name P, to make the revelation clearer to read.) Jorge also asks Also, is it true that after the Twelve Changes I will be able to write INTERFACE Foo; IMPORT Wr; CONST Put = Wr.PutChar; END Foo. or INTERFACE Foo; IMPORT Wr; VAR Put: PROCEDURE (wr: Wr.T; char: CHAR) RAISES {...} := Wr.PutChar END Foo. but not INTERFACE Foo; IMPORT Wr; PROCEDURE Put(wr: Wr.T; char: CHAR) RAISES {...}; END Foo. MODULE Foo; IMPORT Wr; PROCEDURE Put(wr: Wr.T; char: CHAR) RAISES {...} = Wr.PutChar; BEGIN END Foo. He is correct in all three cases.