[M3devel] scope/resolution of foo in interface foo = foo(bar)

Mika Nystrom mika at async.async.caltech.edu
Sat Jan 2 00:02:23 CET 2010


Jay K writes:
...
>
>import foo=3B
>import foo(bar)=3B
>import foo(bar) as foobar=3B
>import foo(bar).T as fooT=3B

Modula-3 doesn't work like that.

You have to say

INTERFACE X = G(Y) ...

IMPORT X

You can't import "G(Y)" directly.  Saves having to worry too much about
name mangling.

Having a generic interface and a normal one with the same name is a common
pattern for me, at least.

You often have a single supertype and then many subtypes that are related
to that supertype by being extended with, say, a field of an arbitrary type.

Then you get...

INTERFACE Stuff; TYPE T ... END Stuff.

GENERIC INTERFACE Stuff(Specializing);
IMPORT Stuff;
TYPE T = Stuff.T OBJECT special : Specializing.T END;
END Stuff.

INTERFACE SpecialStuff = Stuff(Special)

Very convenient to use the same name at the top level, I think.

    Mika

>
>
>I doubt all but the first of these are legal=2C but I also don't think they=
> are very far fetched
>in terms of being reasonable constructs and not difficult to implement.
>
>
>And I'm not sure the presence of the '(' is enough disambiguation for a qui=
>ck human reader
>or a pleasantly simply enough implementation=2C but maybe.
>
>
>All that is to say=2C I don't think disallowing interface foo =3D foo(bar) =
>is so bad.
>
>
> - Jay
>
>From: hosking at cs.purdue.edu
>Date: Fri=2C 1 Jan 2010 14:43:36 -0500
>To: jkrell at elego.de
>CC: m3commit at elegosoft.com
>Subject: Re: [M3commit] CVS Update: cm3
>
>
>
>That's a bug in m3tk scope management.  Probably needs a ticket in the bugs=
> database...
>
>
>On 30 Dec 2009=2C at 15:40=2C Jay Krell wrote:CVSROOT:	/usr/cvs
>Changes by:	jkrell at birch.	09/12/30 15:40:06
>
>Modified files:
>	cm3/m3-libs/m3core/src/word/: Long.i3 Long.m3 Word.i3 Word.m3=20
>	                              m3makefile=20
>Added files:
>	cm3/m3-libs/m3core/src/word/: GenWord.ig GenWord.mg=20
>Removed files:
>	cm3/m3-libs/m3core/src/word/: Word.ig Word.mg=20
>
>Log message:
>	go back to GenWord
>	the other front end (Olivetti m3-tk)
>	doesn't understand
>	INTERFACE Word =3D Word(WordRep) END Word.
>	but it does't understand
>	INTERFACE Word =3D GenWord(WordRep) END Word.
>
> 		 	   		  =
>
>--_3ac6c68d-ca6e-4c55-9f4d-89e33c42a8f7_
>Content-Type: text/html; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
><html>
><head>
><style><!--
>.hmmessage P
>{
>margin:0px=3B
>padding:0px
>}
>body.hmmessage
>{
>font-size: 10pt=3B
>font-family:Verdana
>}
>--></style>
></head>
><body class=3D'hmmessage'>
>I can understand that the name on the left isn't in scope "yet" on the righ=
>t=2C<br>but what is the algorithm for anyone else using IMPORT?<br><br><br>=
>import foo=3B<br>import foo(bar)=3B<br>import foo(bar) as foobar=3B<br>impo=
>rt foo(bar).T as fooT=3B<br><br><br>I doubt all but the first of these are =
>legal=2C but I also don't think they are very far fetched<br>in terms of be=
>ing reasonable constructs and not difficult to implement.<br><br><br>And I'=
>m not sure the presence of the '(' is enough disambiguation for a quick hum=
>an reader<br>or a pleasantly simply enough implementation=2C but maybe.<br>=
><br><br>All that is to say=2C I don't think disallowing interface foo =3D f=
>oo(bar) is so bad.<br><br><br>&nbsp=3B- Jay<br><br><hr id=3D"stopSpelling">=
>From: hosking at cs.purdue.edu<br>Date: Fri=2C 1 Jan 2010 14:43:36 -0500<br>To=
>: jkrell at elego.de<br>CC: m3commit at elegosoft.com<br>Subject: Re: [M3commit] =
>CVS Update: cm3<br><br>
>
><div><span class=3D"ecxApple-style-span" style=3D"border-collapse: separate=
>=3B color: rgb(0=2C 0=2C 0)=3B font-family: Helvetica=3B font-size: 12px=3B=
> font-style: normal=3B font-variant: normal=3B font-weight: normal=3B lette=
>r-spacing: normal=3B line-height: normal=3B text-indent: 0px=3B text-transf=
>orm: none=3B white-space: normal=3B word-spacing: 0px=3B"><span class=3D"ec=
>xApple-style-span" style=3D"border-collapse: separate=3B color: rgb(0=2C 0=
>=2C 0)=3B font-family: Helvetica=3B font-size: 12px=3B font-style: normal=
>=3B font-variant: normal=3B font-weight: normal=3B letter-spacing: normal=
>=3B line-height: normal=3B text-indent: 0px=3B text-transform: none=3B whit=
>e-space: normal=3B word-spacing: 0px=3B"><div style=3D"word-wrap: break-wor=
>d=3B"><span class=3D"ecxApple-style-span" style=3D"border-collapse: separat=
>e=3B color: rgb(0=2C 0=2C 0)=3B font-family: Helvetica=3B font-size: 12px=
>=3B font-style: normal=3B font-variant: normal=3B font-weight: normal=3B le=
>tter-spacing: normal=3B line-height: normal=3B text-indent: 0px=3B text-tra=
>nsform: none=3B white-space: normal=3B word-spacing: 0px=3B"><span class=3D=
>"ecxApple-style-span" style=3D"border-collapse: separate=3B color: rgb(0=2C=
> 0=2C 0)=3B font-family: Helvetica=3B font-size: 12px=3B font-style: normal=
>=3B font-variant: normal=3B font-weight: normal=3B letter-spacing: normal=
>=3B line-height: normal=3B text-indent: 0px=3B text-transform: none=3B whit=
>e-space: normal=3B word-spacing: 0px=3B"><span class=3D"ecxApple-style-span=
>" style=3D"border-collapse: separate=3B color: rgb(0=2C 0=2C 0)=3B font-fam=
>ily: Helvetica=3B font-size: 12px=3B font-style: normal=3B font-variant: no=
>rmal=3B font-weight: normal=3B letter-spacing: normal=3B line-height: norma=
>l=3B text-indent: 0px=3B text-transform: none=3B white-space: normal=3B wor=
>d-spacing: 0px=3B"><span class=3D"ecxApple-style-span" style=3D"border-coll=
>apse: separate=3B color: rgb(0=2C 0=2C 0)=3B font-family: Helvetica=3B font=
>-size: 12px=3B font-style: normal=3B font-variant: normal=3B font-weight: n=
>ormal=3B letter-spacing: normal=3B line-height: normal=3B text-indent: 0px=
>=3B text-transform: none=3B white-space: normal=3B word-spacing: 0px=3B"><s=
>pan class=3D"ecxApple-style-span" style=3D"border-collapse: separate=3B col=
>or: rgb(0=2C 0=2C 0)=3B font-family: Helvetica=3B font-size: 12px=3B font-s=
>tyle: normal=3B font-variant: normal=3B font-weight: normal=3B letter-spaci=
>ng: normal=3B line-height: normal=3B text-indent: 0px=3B text-transform: no=
>ne=3B white-space: normal=3B word-spacing: 0px=3B"><span class=3D"ecxApple-=
>style-span" style=3D"border-collapse: separate=3B color: rgb(0=2C 0=2C 0)=
>=3B font-family: Helvetica=3B font-size: 12px=3B font-style: normal=3B font=
>-variant: normal=3B font-weight: normal=3B letter-spacing: normal=3B line-h=
>eight: normal=3B text-indent: 0px=3B text-transform: none=3B white-space: n=
>ormal=3B word-spacing: 0px=3B"><span class=3D"ecxApple-style-span" style=3D=
>"border-collapse: separate=3B color: rgb(0=2C 0=2C 0)=3B font-family: Helve=
>tica=3B font-size: 12px=3B font-style: normal=3B font-variant: normal=3B fo=
>nt-weight: normal=3B letter-spacing: normal=3B line-height: normal=3B text-=
>indent: 0px=3B text-transform: none=3B white-space: normal=3B word-spacing:=
> 0px=3B"><span class=3D"ecxApple-style-span" style=3D"border-collapse: sepa=
>rate=3B color: rgb(0=2C 0=2C 0)=3B font-family: Helvetica=3B font-size: 12p=
>x=3B font-style: normal=3B font-variant: normal=3B font-weight: normal=3B l=
>etter-spacing: normal=3B line-height: normal=3B text-indent: 0px=3B text-tr=
>ansform: none=3B white-space: normal=3B word-spacing: 0px=3B"><div><span cl=
>ass=3D"ecxApple-style-span" style=3D"font-size: medium=3B"><font class=3D"e=
>cxApple-style-span" color=3D"#0000ff" face=3D"'Gill Sans'">That's a bug in =
>m3tk scope management. &nbsp=3BProbably needs a ticket in the bugs database=
>...</font></span></div></span></span></span></span></span></span></span></s=
>pan></div></span></span>
></div>
><br><div><div>On 30 Dec 2009=2C at 15:40=2C Jay Krell wrote:</div><br class=
>=3D"ecxApple-interchange-newline"><blockquote><div>CVSROOT:<span class=3D"e=
>cxApple-tab-span" style=3D"white-space: pre=3B">	</span>/usr/cvs<br>Changes=
> by:<span class=3D"ecxApple-tab-span" style=3D"white-space: pre=3B">	</span=
>>jkrell at birch.<span class=3D"ecxApple-tab-span" style=3D"white-space: pre=
>=3B">	</span>09/12/30 15:40:06<br><br>Modified files:<br><span class=3D"ecx=
>Apple-tab-span" style=3D"white-space: pre=3B">	</span>cm3/m3-libs/m3core/sr=
>c/word/: Long.i3 Long.m3 Word.i3 Word.m3 <br><span class=3D"ecxApple-tab-sp=
>an" style=3D"white-space: pre=3B">	</span> &nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B=
>&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nb=
>sp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=
>=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3Bm3makefile <br>Added fil=
>es:<br><span class=3D"ecxApple-tab-span" style=3D"white-space: pre=3B">	</s=
>pan>cm3/m3-libs/m3core/src/word/: GenWord.ig GenWord.mg <br>Removed files:<=
>br><span class=3D"ecxApple-tab-span" style=3D"white-space: pre=3B">	</span>=
>cm3/m3-libs/m3core/src/word/: Word.ig Word.mg <br><br>Log message:<br><span=
> class=3D"ecxApple-tab-span" style=3D"white-space: pre=3B">	</span>go back =
>to GenWord<br><span class=3D"ecxApple-tab-span" style=3D"white-space: pre=
>=3B">	</span>the other front end (Olivetti m3-tk)<br><span class=3D"ecxAppl=
>e-tab-span" style=3D"white-space: pre=3B">	</span>doesn't understand<br><sp=
>an class=3D"ecxApple-tab-span" style=3D"white-space: pre=3B">	</span>INTERF=
>ACE Word =3D Word(WordRep) END Word.<br><span class=3D"ecxApple-tab-span" s=
>tyle=3D"white-space: pre=3B">	</span>but it does't understand<br><span clas=
>s=3D"ecxApple-tab-span" style=3D"white-space: pre=3B">	</span>INTERFACE Wor=
>d =3D GenWord(WordRep) END Word.<br></div></blockquote></div><br> 		 	   		=
>  </body>
></html>=
>
>--_3ac6c68d-ca6e-4c55-9f4d-89e33c42a8f7_--



More information about the M3devel mailing list