home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.modula3
- Path: sparky!uunet!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watserv1!mhcoffin
- From: mhcoffin@tolstoy.uwaterloo.ca (Michael Coffin)
- Subject: Re: Constructors in Modula-3
- In-Reply-To: pk@rwthi3.informatik.rwth-aachen.de's message of 14 Sep 92 15:00:57 GMT
- Message-ID: <MHCOFFIN.92Sep14133341@tolstoy.uwaterloo.ca>
- Sender: news@watserv1.uwaterloo.ca
- Organization: Dept. of Computer Science, University of Waterloo
- References: <ANDRU.92Sep14011727@concerto.lcs.mit.edu>
- <1992Sep14.150057.4225@Urmel.Informatik.RWTH-Aachen.DE>
- Date: Mon, 14 Sep 1992 18:33:41 GMT
- Lines: 28
-
-
- I proposed what I think is a simple solution to this problem a couple
- months ago, but got no response. My solution was to add a pragma, say
- <*NO NEW*>, that can be affixed to type declarations in an interface.
- E.g.,
-
- INTEFACE foo
- <*NO NEW*> TYPE T <: U;
- PROCEDURE New(x: INTEGER): T;
- END foo.
-
- In the presence of this type declaration, NEW cannot be used to create
- objects of type T. This forces the user of the interface to use
- whatever constructor procedures are supplied in the interface; in this
- case "New". (Of course, NEW could still be used inside a module that
- implements foo.)
-
- What I would really like to see is a keywork, say PRIVATE, that does
- what <*NO NEW*> does. I think it is a mistake in the language design
- that Modula-3 tries to guess whether NEW should be allowed based on
- how much is known about a type. Whether NEW is allowed is really
- orthogonal to whether a type is completely opaque, partly revealed, or
- fully revealed.
-
- -mike
-
-
-
-