Thanks for your explanation, Alex On Thu, Dec 16, 2021 at 10:24 AM Alexander Burger <a...@software-lab.de> wrote:
> > First of all, forget other Lisps! I always say it is best if you start with > PicoLisp without knowing "Lisp". > :) That's a nice advice but sadly I feel I can't do that ;-) > The term "improper list" does not exist in PicoLisp. Everything is either a > number, a symbol or a pair. > As you sure know proper or improper list always exist because is a semantic convention or noun, every list is a pair just only happen that when a list (a chained dotted pair) ends in NIL we call it proper list and when not ending in NIL but in any other atom, we call it improper list. So picolisp HAS proper and improper list ;-) in fact a circular list is a kind of improper list and we all known picolisp has circular lists > As we are interpreter-only, every function is free to decide for itself > how to > handle its arguments. Thus *every* built-in function is an FSUBR, always > of the > form (fun . args). > > I think I have a problem with picolisp documentation (my fault), it says "A dotted pair notation in the argument list like (... 'any . prg) indicates an unevaluated list of further arguments." which is what you said in previous paragraph and the way of constructing functions not evaluating arguments, to me this means in function application you should have a list of function name and arguments, like this (f) , (f 1) , (f a b c) ... being the doc of fun "(fun . args)" then: (fun ) ; args = '() (fun 1) ; args = '(1) (fun a b) ; args = '(a b) so a doc like "(de sym . any) -> sym" is quite different from a doc like "(quote . any) -> any". doc "(de sym . any) -> sym" means you should pass at least one argument and the rest if any are collected in a list, so every function call should be the kind of: (de f ) ; any = '() (de f 3) ; any = '(3) (de f (x) (+ 2 1)) ; any = '((X) (+ 2 1)) but it cannot be: (de f . 4) ; any = ?? but it can: (def f . 4) ; makes f = 4 and so any should not be a list but atom 4, contrary to doc definition "A dotted pair like (... 'any . prg) indicates an unevaluated list of further arguments." And so what means the doc "(quote . any) -> any"? following doc convention any should be binded to an evaluated list of arguments, and arguments can be anything or nothing: (quote) ; any = '() (quote 1) ; any = '(1) (quote a b) ; any = '(a b) but again what about (quote . a) ? what to bind to any? it only can be atom a and thus is what really happen but as said in doc, any is a list not an atom For my mind this is already so bad, but it's even worse because the behaviour is not predictible: (+ 1 . 2) does not return 3 but 1 ok, you can assume you can pass arguments to functions in cdr part of cell and thus (quote . a) is another way to express normal lisp behaviour (quote a) and thus if (quote . a) is a, then you can say (quote a) is effectivey like (quote . (a . NIL)) and thus your are passsing a list to quote returning (a), but it should work also for + or print I think the point is most lisp assume parameters to functions are always passed in CAR position of cells, which is the same of saying all functiion applications are proper list, while picolisp allow to pass arguments to functions in CDR position of cells and thus function applications are not proper list, but the problem is it seems this is not a general behaviour since some functions work with parameters in cdr position while others don't. Maybe I'm misunderstanding details and after all picolisp is breaking traditions as stated in documentation, but this behaviour blows my square mind ;-) Anyway I think it worths to think about all this to further understand picolisp internals and picolisp way of lisp ;-) best regards