home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.lisp
- Path: sparky!uunet!cs.utexas.edu!hellgate.utah.edu!eeide
- From: eeide%asylum.cs.utah.edu@cs.utah.edu (Eric Eide)
- Subject: Mutually Referential DEFSTRUCT Slot Types: How?
- Message-ID: <EEIDE.92Aug12120727@asylum.cs.utah.edu>
- Organization: University of Utah Department of Computer Science
- Distribution: comp
- Date: 12 Aug 92 12:07:27
- Lines: 32
-
- I would like to write something like the following in Common Lisp:
-
- (defstruct a
- (slot nil :type b))
-
- (defstruct b
- (slot nil :type a))
-
- How can I do this? From my reading of CLtL2, B does not become a valid type
- specifier until the (DEFSTRUCT B ...) form is evaluated, so I can't say that
- an A's slot is of type B. I suppose I might change the first DEFTSTRUCT to
-
- (defstruct a
- (slot nil :type (satisfies b-p)))
-
- but I think that this type specifier would not give my compiler enough
- information to allow it to opencode my structure accessors. Speed is important
- in my application, but probably not critically so.
-
- Second, how can I create an instance of either of these objects, while keeping
- the declared types accurate?
-
- My current plan is to forgo the type declaration of A's SLOT, unless somebody
- can tell me how to do write mutually recursive structure slot type declarations
- and then instantiate those structures correctly.
-
- Thanks for any pointers!
-
- --
- -------------------------------------------------------------------------------
- Eric Eide | University of Utah Department of Computer Science
- eeide@cs.utah.edu | Buddhist to hot dog vendor: "Make me one with everything."
-