Hi Rick + Thorsten, On Sat, Aug 08, 2015 at 11:43:03PM +0200, Thorsten Jolitz wrote: > Rick Hanson <cryptor...@gmail.com> writes: > > > Yeah, sorry. I had this on the mind -- a different animal altogether. > > > > $ sbcl > > * (let ((X (+ 3 4))) `(hello ,X ,(- X 9))) > > (HELLO 7 -2) > > Maybe I was confused by Emacs Lisp a bit too: > > ,---- > | (let ((x (+ 3 4)) > | (y (+ 5 6))) > | `(+ 5 x ,y)) > | > | -> (+ 5 x 11) > `----
Yes, this is confusing. In CL and Emacs the backquote is actually a *function*, in the same way as 'quote' is a function in PicoLisp. In all systems, the quote character (') is a read-macro: PicoLisp '(a b c) = (quote a b c) Other '(a b c) = (quote (a b c)) In PicoLisp, the backquote is *not* a function. It is immediately replaced by the reader with the result of the evaluation. In other Lisps, the backquote is probably also a read-macro, similar to 'quote', in that it returns a function call to be evaluated later at runtime. It could be something like `(a b ,c d) = (backquote a b , c d) In PicoLisp, the function closest to backquote (though a litte different) is 'fill'. > ,---- > | A single backquote character "`" will cause the reader to evaluate > | the following expression, and return the result. > | > | : '(a `(+ 1 2 3) z) > | -> (a 6 z) > | > | A tilde character ~ inside a list will cause the reader to evaluate > | the following expression, and (destructively) splice the result into > | the list. > | > | : '(a b c ~(list 'd 'e 'f) g h i) > | -> (a b c d e f g h i) > `---- > > it looks to me as if the difference between PicoLisp and others (like > Emacs Lisp) must be rather in the 'let than in the read macros, since No! Nothing to do with 'let'. > the combination "quote/backquote" in PicoLisp is equivalent to the > combination "backquote/comma" in other Lisps, and works the same, except > inside let bindings: Nonono! The backquote in PicoLisp has NOTHING at all to do with the 'quote' function. It is a completely separate thing. 'quote' is just a normal function, which at *runtime* returns its arguments un-evaluated. It makes perfect sense to have backquote without 'quote' : (de foo (X) (* X `(+ 3 4)) ) : (pp 'foo) (de foo (X) (* X 7) ) It seems still not to be clear that the important point is WHEN an expression is evaluated. Please try to understand what READ/EVAL really means. It is the same in all Lisps in that regard. > PicoLisp: > > ,---- > | $ pil + > | : (let X (+ 2 3) '(3 4 `X)) > | -> (3 4 NIL) Yes. The expression (let X (+ 2 3) '(3 4 `X)) only makes sense if 'X' was defined before it is READ. e.g. $ pil + : (setq X 7) ... : (let X (+ 2 3) '(3 4 `X)) -> (3 4 7) > vs Emacs Lisp: > > ,---- > | (let ((X (+ 2 3))) `(3 4 ,X)) > | -> (3 4 5) > | > | `(3 4 ,(+ 2 3)) > | -> (3 4 5) > `---- > > How would the above behavior inside let bindings be achieved in > PicoLisp? Either : (let X (+ 2 3) (list 3 4 X)) # I would prefer a simple 'list' -> (3 4 5) or : (let X (+ 2 3) (fill (3 4 X) 'X)) # Rick tried 'fill' too -> (3 4 5) or : (let @X (+ 2 3) (fill (3 4 @X))) -> (3 4 5) or whatever function you like to build the list. Note that also in CL and Emacs the backquote function builds a list at *runtime*, just like 'list' or 'fill' do. ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe