home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / modula3 / 910 < prev    next >
Encoding:
Text File  |  1992-09-14  |  1.6 KB  |  42 lines

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