From: cyberbob
Subject: SETF problem with CLISP
Date: 
Message-ID: <20020227233333.11246.qmail@gacracker.org>
Hello!

I've a program that works under cmucl.  OTOH i've some problems with it
under CLISP.

Here is the problematic code snippet:

(defun rejoin-after-kick (server msg)
  (when (and (eq (irc-message-type msg) 'kick)
             (equal (server-nick server) (irc-message-target msg)))
    (setf (server-channels-on server)
          (remove (irc-message-channel msg)
                  (server-channels-on server) :test #'equalp))))

Server and irc-message are structs, the code snippet does this: when it
sees that it has been kicked from a channel it removes that channel's
name from the channels-on list.

Now let's see a CLISP session: the bot connects, etc, and when I kick it
I get:

,----
| *** - EVAL: the function (SETF SERVER-CHANNELS-ON) is undefined
| 1. Break [2]>
`----

Now let's take a look at the variables:

,----
| *** - EVAL: the function (SETF SERVER-CHANNELS-ON) is undefined
| 1. Break [2]> :w
| 
| EVAL frame for form 
| ((SETF SERVER-CHANNELS-ON)
|  (REMOVE (IRC-MESSAGE-CHANNEL MSG) (SERVER-CHANNELS-ON SERVER) :TEST
|   #'EQUALP)
|  #:G1227)
| 1. Break [2]> (IRC-MESSAGE-CHANNEL MSG)
| "#foo"
| 1. Break [2]> (SERVER-CHANNELS-ON SERVER)
| ("#foo")
| 1. Break [2]>
`----

What's really confuses me is that when I copy and paste the original
setf sexpression into the eval loop it gets evaled fine!

,----
| 1. Break [2]> (SERVER-CHANNELS-ON SERVER)
| ("#foo")
| 1. Break [2]> (setf (server-channels-on server)
|                     (remove (irc-message-channel msg)
|                       (server-channels-on server) :test #'equalp))
| NIL
| 1. Break [2]> (server-channels-on server)
| NIL
| 1. Break [2]> 
`----

Please enligthen me, thanks in advance! :-)

-- 
cyberbob

From: Barry Margolin
Subject: Re: SETF problem with CLISP
Date: 
Message-ID: <TAef8.23$Rd7.6460@paloalto-snr1.gtei.net>
In article <··························@gacracker.org>,
cyberbob  <··································@[127.1]> wrote:
>Hello!
>
>I've a program that works under cmucl.  OTOH i've some problems with it
>under CLISP.
>
>Here is the problematic code snippet:
>
>(defun rejoin-after-kick (server msg)
>  (when (and (eq (irc-message-type msg) 'kick)
>             (equal (server-nick server) (irc-message-target msg)))
>    (setf (server-channels-on server)
>          (remove (irc-message-channel msg)
>                  (server-channels-on server) :test #'equalp))))
>
>Server and irc-message are structs, the code snippet does this: when it
>sees that it has been kicked from a channel it removes that channel's
>name from the channels-on list.
>
>Now let's see a CLISP session: the bot connects, etc, and when I kick it
>I get:
>
>,----
>| *** - EVAL: the function (SETF SERVER-CHANNELS-ON) is undefined
>| 1. Break [2]>
>`----

I suspect you compiled REJOIN-AFTER-KICK before loading the structure
definition.  CLISP's DEFSTRUCT probably generates setf-expanders rather
than setf-functions, so the compiler has to know about the structure when
compiling these SETFs.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: cyberbob
Subject: Re: SETF problem with CLISP
Date: 
Message-ID: <20020228173436.13403.qmail@gacracker.org>
>>>>> Barry Margolin <······@genuity.net> wrote:

Hello Barry!

> In article <··························@gacracker.org>,
> cyberbob  <··································@[127.1]> wrote:

>> I've a program that works under cmucl.  OTOH i've some problems with
>> it under CLISP.

>> *** - EVAL: the function (SETF SERVER-CHANNELS-ON) is undefined

> I suspect you compiled REJOIN-AFTER-KICK before loading the structure
> definition.  CLISP's DEFSTRUCT probably generates setf-expanders
> rather than setf-functions, so the compiler has to know about the
> structure when compiling these SETFs.

You're right, after I loaded the structure definitions first, my
problem went away, thank you!

-- 
cyberbob