3 ms·
It gets tricky. Bracket/dwim forms can designate access to objects, because sequences are funcallable. So we can do: (set [a b] c) What does that look like?
by kazinator 10y ago
It gets tricky. Bracket/dwim forms can designate access to objects, because sequences are funcallable. So we can do:
(set [a b] c)
What does that look like?
1> (sys:expand '(set [a b] c))
(let ((#:g0138 (sys:lisp1-value
b))
(#:g0137 c))
(sys:lisp1-setq
a (sys:dwim-set (sys:lisp1-value
a) #:g0138
#:g0137))
#:g0137)
The a and b forms turned into (sys:lisp1-value a) and (sys:lisp1-value b). These secret operators bring in the name lookup semantics anywhere it is required, disembodied from the dwim operator. Also sys:lisp1-setq is used to store the updated sequence back into a. sys:setq can't be used because a could be a function binding in the given scope.
There are hacks you can do in Common Lisp to achieve a bit of a Lisp-1 style, but not to such detail. See this piece of documentation under labels and flet:
http://www.nongnu.org/txr/txr-manpage.html#N-0209307D http://www.nongnu.org/txr/txr-manpage.html#N-0209307D
"Furthermore, function bindings introduced by labels and flet also shadow symbol macros defined by symacrolet, when those symbol macros occur as arguments of a dwim form."
A test case for this is the following, which must produce (1 1 1):
(let ((g (lambda (x) 0)))
(symacrolet ((f g))
(flet ((f (x) 1))
[mapcar f '(a a a)]))) ;; Lisp-1 f: flet shadows symbol macro
However, this must produce (0 0 0):
(let ((g (lambda (x) 0)))
(symacrolet ((f g))
(flet ((f (x) 1))
(mapcar f '(a a a))))) ;; now Lisp-2 var reference