home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / lisp / 2207 < prev    next >
Encoding:
Internet Message Format  |  1992-08-12  |  1.6 KB

  1. Path: sparky!uunet!think.com!barmar
  2. From: barmar@think.com (Barry Margolin)
  3. Newsgroups: comp.lang.lisp
  4. Subject: Re: Mutually Referential DEFSTRUCT Slot Types: How?
  5. Date: 13 Aug 1992 09:09:15 GMT
  6. Organization: Thinking Machines Corporation, Cambridge MA, USA
  7. Lines: 39
  8. Distribution: comp
  9. Message-ID: <16d8rrINNm7q@early-bird.think.com>
  10. References: <EEIDE.92Aug12120727@asylum.cs.utah.edu>
  11. NNTP-Posting-Host: gandalf.think.com
  12.  
  13. In article <EEIDE.92Aug12120727@asylum.cs.utah.edu> eeide%asylum.cs.utah.edu@cs.utah.edu (Eric Eide) writes:
  14. >I would like to write something like the following in Common Lisp:
  15. >
  16. >  (defstruct a
  17. >    (slot nil :type b))
  18. >
  19. >  (defstruct b
  20. >    (slot nil :type a))
  21.  
  22. (defstruct a
  23.   slot)
  24.  
  25. (defstruct b
  26.   (slot nil :type a))
  27.  
  28. (declaim (ftype a-slot (a) b))
  29.  
  30. Except that this doesn't permit you to declare that the type of the new
  31. value when SETFing A-SLOT must be B.
  32.  
  33. >but I think that this type specifier would not give my compiler enough
  34. >information to allow it to opencode my structure accessors.  Speed is important
  35. >in my application, but probably not critically so.
  36.  
  37. I'm not sure that this particular set of declarations is likely to be used
  38. by most implementations.  What kind of open coding do you expect it to
  39. enable?
  40.  
  41. >Second, how can I create an instance of either of these objects, while keeping
  42. >the declared types accurate?
  43.  
  44. My type declaration allows this, since it doesn't require that A-SLOT be
  45. initialized to a B.  It only requires that it be assigned a B before being
  46. read.
  47. -- 
  48. Barry Margolin
  49. System Manager, Thinking Machines Corp.
  50.  
  51. barmar@think.com          {uunet,harvard}!think!barmar
  52.