home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / function / 1471 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.6 KB  |  56 lines

  1. Newsgroups: comp.lang.functional
  2. Path: sparky!uunet!spool.mu.edu!sdd.hp.com!ux1.cso.uiuc.edu!cs.uiuc.edu!morrison
  3. From: morrison@cs.uiuc.edu (Vance Morrison)
  4. Subject: Values escaping their type definition
  5. Message-ID: <BzDIL1.B4I@cs.uiuc.edu>
  6. Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
  7. Date: Wed, 16 Dec 1992 22:31:49 GMT
  8. Lines: 46
  9.  
  10.  
  11. Hello,
  12.  
  13. I have just realized something about ML that I find rather odd and 
  14. I am hoping to get some advice about consequences.
  15.  
  16. The oddity is that a value can escape the scope in which its type
  17. definition was made.   Thus
  18.  
  19.  
  20.     let 
  21.        datatype aType = constA | constB of int;
  22.     in
  23.        constA
  24.     end;
  25.  
  26.  
  27. This of course returns the value 'constA', in the outer scope, but
  28. in this scope there is no type for this value!!
  29.  
  30. I tried this SML of NJ and it accepted it and returned the message
  31.  
  32.         val it = constA : ?.aType
  33.  
  34. It seems to me that this can cause problem with the sematics of
  35. the language and would be a problem in any language that allows
  36. type definitions in inner scopes.  
  37.  
  38. Now my problem is that I don't know what the exact problems this 
  39. could cause, and I was hoping that those who have had more experience
  40. both defining and implementing ML could give their input.  
  41.  
  42. I have a copy of the Definition of ML, so if something there would
  43. make this clear, please feel free to refer to it.
  44.  
  45. Vance
  46.  
  47.  
  48. P.S.  :  I am also curious about a discussion about the problem
  49.      with arbitrary Type definitions in signatures.  Unfortuately
  50.      I did not save it.  If someone has the reference to the
  51.      relevant passage in the Definition Book I would love to
  52.      get that too.
  53.  
  54.  
  55.  
  56.