Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!swrinde!hookup!news.sprintlink.net!EU.net!uknet!festival!edcogsci!jeff
From: jeff@aiai.ed.ac.uk (Jeff Dalton)
Subject: Re: declaring struct slot setter before defstruct
Message-ID: <D2IC4x.4E@cogsci.ed.ac.uk>
Sender: usenet@cogsci.ed.ac.uk (C News Software)
Nntp-Posting-Host: bute-alter.aiai.ed.ac.uk
Organization: AIAI, University of Edinburgh, Scotland
References: <1995Jan15.170110.183@leeds.ac.uk>
Date: Mon, 16 Jan 1995 16:50:57 GMT
Lines: 23

In article <1995Jan15.170110.183@leeds.ac.uk> rodw@cbl.leeds.ac.uk (R J Williams) writes:
>Hi,
>
>Is it possible to declare a stucture slot setter before the structure itself
>is defined?  For example:
>
>(defun test (struct)
>  (setf (ex-val struct) 'a))
>
>(defstruct ex
>  (val 'b))
>
>Clearly I can reorganise the code but I was wondering if it is possible.

It might be in some implementations, but it's not portable.

Given Common Lisp's (SETF name) convention, it ought to work.
The SETF of EV-VAL should turn into a call to (SETF EX-VAL), and
the DEFSTRUCT should define (SETF EX-VAL).  But unfortunately,
this is one of the inconsistencies / pitfalls in Common Lisp.
It should work that way, but it doesn't.

-- jeff
