home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / function / 1472 < prev    next >
Encoding:
Internet Message Format  |  1992-12-17  |  1.2 KB

  1. Path: sparky!uunet!spool.mu.edu!uwm.edu!linac!att!att!allegra!alice!ark
  2. From: ark@alice.att.com (Andrew Koenig)
  3. Newsgroups: comp.lang.functional
  4. Subject: Re: Values escaping their type definition
  5. Message-ID: <24432@alice.att.com>
  6. Date: 17 Dec 92 15:28:53 GMT
  7. Article-I.D.: alice.24432
  8. References: <BzDIL1.B4I@cs.uiuc.edu>
  9. Reply-To: ark@alice.UUCP ()
  10. Organization: AT&T Bell Laboratories, Murray Hill NJ
  11. Lines: 30
  12.  
  13. In article <BzDIL1.B4I@cs.uiuc.edu> morrison@cs.uiuc.edu (Vance Morrison) writes:
  14.  
  15. >     let 
  16. >        datatype aType = constA | constB of int;
  17. >     in
  18. >        constA
  19. >     end;
  20.  
  21. > This of course returns the value 'constA', in the outer scope, but
  22. > in this scope there is no type for this value!!
  23.  
  24. More precisely, it returns a value that the compiler knows how to print
  25. as constA, of a type which you have no way to name.  Why is that any
  26. more disturbing from this?
  27.  
  28.     let
  29.        datatype aType = constA | constB of int
  30.        type aType = int
  31.     in
  32.        constA
  33.     end
  34.  
  35. Here you can mention constA but you can't write its type either, because
  36. aType is hidden.
  37.  
  38. Incidentally, in both cases, aType, constA, and constB are out of scope
  39. after the `end' and you can't use any of them.
  40. -- 
  41.                 --Andrew Koenig
  42.                   ark@europa.att.com
  43.