[slime-devel] custom tweaks for object system

David O'Toole dto at gnu.org
Wed Aug 20 07:15:53 UTC 2008

Hello folks. I use SLIME for all my Common Lisp interaction. I recently
implemented a custom prototype-based object system for a roguelike game
project i'm doing. With the use of reader macros and some code walking,
I can write methods like this: 

> (define-method equip cell (item &optional slot)
>   (when [is-equipment item]
>     (let ((match [equipment-match self item]))
>       (setf (getf <equipment> 
>   (or slot (first match)))
>     item)
>       [add-category item :equipped]
>       ;; remove from inventory
>       [remove-item self item])))

The syntax is [method-name object &rest args] and <foo> represents
(field-value self :foo)

Another example: 

> (define-method forward world (method-key &rest args)
>   "Send unhandled messages to the player object.
> This is where most world computations start, because nothing happens
> in a roguelike until the user has pressed a key."
>   (let ((player <player>)
> (phase-number <phase-number>))
>     (with-message-queue <message-queue> 
>       ;; send the message, possibly generating queued messages
>       (apply #'send method-key player args)
>       ;; process any messages that were generated
>       [process-messages self]
>       ;; update the player's action points
>       [take-turn player phase-number]
>       ;; if this is the player's last turn, begin the cpu phase
>       ;; otherwise, stay in player phase and exit
>       (unless [needs-turn player phase-number]
> [run-cpu-phase self])))
>   nil)

I would like this to work with SLIME's arguments list lookup and so on.
My system retains all the documentation and arglist info at runtime so I
could probably hook this up somehow. 

Any suggestions on how I could make this work with SLIME?

More information about the slime-devel mailing list