Re: The limits of lisps synatactic gymnastics? (i sure hope not)



Wade Humeniuk <whumeniu+anti+spam@xxxxxxxxx> writes:

> Though not particularly recommended, CLOS is much better...
>
>
> (defmacro defobject (name)
> `(let ((slots nil))
> (defun ,name (slot-name)
> (getf slots slot-name))
> (defun (setf ,name) (value slot-name)
> (setf (getf slots slot-name) value))))
>
> CL-USER 1 > (defobject jimmy)
> (SETF JIMMY)
>
> CL-USER 2 > (setf (jimmy 'name) "jimmy")
> "jimmy"
>
> CL-USER 3 > (setf (jimmy 'age) 74)
> 74
>
> CL-USER 4 > (jimmy 'name)
> "jimmy"
>
> CL-USER 5 > (jimmy 'age)
> 74
>
> CL-USER 6 > (jimmy 'height)
> NIL

However I suspect the OP may also want to be able to say:

> (defun foo (obj) (obj 'name))
FOO

> (foo jimmy)
"jimmy"

I think the OP has no choice but to write his own interpreter or
compiler since his desired language (as far as I cen tell, reading
between the lines of his original post) has a fundamentally different
evaluation rule for cons forms than Common Lisp does. But, as we've
been trying to explain to Dr. Flying Frog, that's one of Lisp's
strengths so the OP shouldn't be deterred, assuming for the sake of
argument, that having such a language would actually solve some real
problem for him.

-Peter

--
Peter Seibel * peter@xxxxxxxxxxxxxxx
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp * http://www.gigamonkeys.com/book/
.