Re: sharp-back syntax



In article <1175308121.426059.83610@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
nallen05@xxxxxxxxx wrote:

I'm talking about both versions. You have to walk through the code
looking for the implicit lambda vars, so that you construct the lambda
list. But if there are any quoted symbols that look like your implicit
lambda variables you'll add them to the lambda list. E.g. I'd expect
this:

(mapcar #$(eq $1 '$2) '(a b $2 c))

to generate a "wrong number of arguments" error because it will expand
into:

(mapcar #'(lambda ($1 $2) (eq $1 '$2)) '(a b $2 c))

ah, right. thanks for pointing that out.

(defun sharp-back-expand (form)
(let (vs)
(labels ((rfn (x)
(if (sharp-back-var-p x)
(pushnew x vs)
(when (listp x)
(unless (eql (first x) 'quote) ;
(mapc #'rfn x))))))
(rfn form)
`(lambda ,(nreverse vs) ,form))))

That's not the only place where symbols are not evaluated as variables.

#$(let (($2 1))
(+ $1 $2))

(defmacro my-quote (x) `(quote ,x))

(mapcar #$(eq $1 (my-quote $2)) '(a b $2 c))

--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.



Relevant Pages

  • Re: sharp-back syntax
    ... looking for the implicit lambda vars, so that you construct the lambda ... (defun sharp-back-expand (form) ...
    (comp.lang.lisp)
  • Re: sharp-back syntax
    ... | looking for the implicit lambda vars, so that you construct the lambda ... | expand into: ... (NIL NIL T NIL) ...
    (comp.lang.lisp)