Hello, this message is somehow related to the one with subject "Feature
request - 'fill'"

After playing with fill and quote in picolisp I've found picolisp
implmentation of quote is a bit "strange" in terms of lisp tradition.

In lisp quote is usually a special form than returns the form passed as
parameter and accepting only and only one parameter, thus:

(quote a)  -> a
(quote (quote a)) -> 'a
(quote (a b c)) -> (a b c)
(quote '(a b c)) -> '(a b c)
(quote) ->  *ERROR*
(quote a b c)  ->  *ERROR*

where ' is an alias for quote,  so   (quote '(a b)) = (quote (quote (a b)))

But this is not the case in picolisp, since quote accept several arguments
it is forced to return always a list even when quoting an atom:

(quote a) -> (a)
(quote 'a) -> ('a)
(quote (a)) -> ((a))
(quote '(a)) -> ('(a))
(quote) -> NIL    ; which is '()
(quote a b c) -> (a b c)
(quote 7) -> (7)

I think this is incorrect because 7 is not (7), 7 is an atom and it should
still be when quoted, but picolisp turns it into a list

This also have problems, for example in most lisp you are expected to
safely do:

(setq a 4) -> 4
(quote a)  -> a
(eval (quote a)) -> 4

But in picolisp you get:

(set a 4) -> 4
(quote a) -> (a)
(eval (quote a))
Segmentation fault

This is because of converting an atom into a list and then evaluating it
tries to execute a function, the internal one at address 4, and thus you
get a segmentation.

This does not happen trying to evaluate a constant number just due to
picolisp special treatment of lists of numbers to avoid quotation:

(eval (quote 7)) -> (7)

Also there's no coherence between quote form and ' read macro:

(quote 3) -> (3)
'3 -> 3
(quote a) -> (a)
'a -> a
(quote (a b)) -> ((a b))
'(a b) -> (a b)
(quote '(a b)) -> ('(a b))
''(a b) -> '(a b)
(quote (quote (a b)) -> ('((a b)))

even when in the manual it's said "... read-macro in Lisp is the single
quote character ', which expands to a call of the quote function"

it seems read macro ' behaves as expected in lisp but quote form does not.

Maybe I misunderstand the details in quote form because if you use it as
not proper list it seems to behave as it should be:

(quote . 3) -> 3
(quote . a) -> a
(quote . (a b)) -> (a b)
(quote . '(a b)) -> '(a b)
(quote . (quote . (a b)) -> '(a b)

But this is a uncommon syntax and I feel an incorrect use for most lisp out
there.

May you explain and/or discuss this ?
shouldn't be possible that ' read-macro translate transparently into quote
forms and also quote forms and ' read macro were equivalent?
why not restrict quote form to use just one argument as most lisp do?

thanks and best regards

Reply via email to