home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!think.com!barmar
- From: barmar@think.com (Barry Margolin)
- Newsgroups: comp.lang.lisp
- Subject: Re: Mutually Referential DEFSTRUCT Slot Types: How?
- Date: 13 Aug 1992 09:09:15 GMT
- Organization: Thinking Machines Corporation, Cambridge MA, USA
- Lines: 39
- Distribution: comp
- Message-ID: <16d8rrINNm7q@early-bird.think.com>
- References: <EEIDE.92Aug12120727@asylum.cs.utah.edu>
- NNTP-Posting-Host: gandalf.think.com
-
- In article <EEIDE.92Aug12120727@asylum.cs.utah.edu> eeide%asylum.cs.utah.edu@cs.utah.edu (Eric Eide) writes:
- >I would like to write something like the following in Common Lisp:
- >
- > (defstruct a
- > (slot nil :type b))
- >
- > (defstruct b
- > (slot nil :type a))
-
- (defstruct a
- slot)
-
- (defstruct b
- (slot nil :type a))
-
- (declaim (ftype a-slot (a) b))
-
- Except that this doesn't permit you to declare that the type of the new
- value when SETFing A-SLOT must be B.
-
- >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.
-
- I'm not sure that this particular set of declarations is likely to be used
- by most implementations. What kind of open coding do you expect it to
- enable?
-
- >Second, how can I create an instance of either of these objects, while keeping
- >the declared types accurate?
-
- My type declaration allows this, since it doesn't require that A-SLOT be
- initialized to a B. It only requires that it be assigned a B before being
- read.
- --
- Barry Margolin
- System Manager, Thinking Machines Corp.
-
- barmar@think.com {uunet,harvard}!think!barmar
-