home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / lisp / 2201 < prev    next >
Encoding:
Text File  |  1992-08-12  |  1.6 KB  |  43 lines

  1. Newsgroups: comp.lang.lisp
  2. Path: sparky!uunet!cs.utexas.edu!hellgate.utah.edu!eeide
  3. From: eeide%asylum.cs.utah.edu@cs.utah.edu (Eric Eide)
  4. Subject: Mutually Referential DEFSTRUCT Slot Types: How?
  5. Message-ID: <EEIDE.92Aug12120727@asylum.cs.utah.edu>
  6. Organization: University of Utah Department of Computer Science
  7. Distribution: comp
  8. Date: 12 Aug 92 12:07:27
  9. Lines: 32
  10.  
  11. I would like to write something like the following in Common Lisp:
  12.  
  13.   (defstruct a
  14.     (slot nil :type b))
  15.  
  16.   (defstruct b
  17.     (slot nil :type a))
  18.  
  19. How can I do this?  From my reading of CLtL2, B does not become a valid type
  20. specifier until the (DEFSTRUCT B ...) form is evaluated, so I can't say that
  21. an A's slot is of type B.  I suppose I might change the first DEFTSTRUCT to
  22.  
  23.   (defstruct a
  24.     (slot nil :type (satisfies b-p)))
  25.  
  26. but I think that this type specifier would not give my compiler enough
  27. information to allow it to opencode my structure accessors.  Speed is important
  28. in my application, but probably not critically so.
  29.  
  30. Second, how can I create an instance of either of these objects, while keeping
  31. the declared types accurate?
  32.  
  33. My current plan is to forgo the type declaration of A's SLOT, unless somebody
  34. can tell me how to do write mutually recursive structure slot type declarations
  35. and then instantiate those structures correctly.
  36.  
  37. Thanks for any pointers!
  38.  
  39. --
  40. -------------------------------------------------------------------------------
  41. Eric Eide          |          University of Utah Department of Computer Science
  42. eeide@cs.utah.edu  | Buddhist to hot dog vendor: "Make me one with everything."
  43.