# Re: a bunch of questions about syntax

```Thank you Alex for your patience, I see I have a severe confussion about
how picolisp manages lists```
```
let's start by the begining... as far as I know   (f a b 4)  is just a list
equivalent to (f . (a . (b . (4 . NIL))))  and the fact being also a
function call to function f applying parameters a b 4 is just a matter of
"convention", simply when picolisp evals a list with a first item not being
a number it supposes it's a function call and tries to evaluate first item
(it doesn't matter if first item is a symbol or another list, it gets
evaluated) which is supposed to be evaluated to a function value

With this point of view I understand what you mean when saying  (f 1 a b c)
is just the same as (f 1 . (a b c)) and thus you can view a, b, c as a list
so you can describe this funcion as (f num . 'lst), ok, but also I think
you could describe the function f also as (f . 'lst) . The only difference
is that using the latter you are only interested in remark you pass to f a
sequence of symbols (which form a list) while using the former description
you are interested in remark the first symbol in the sequence is supposed
to be a number and also it is not evaluated.

But if you describe a function like (g num 'lst) is a quite different thing
because you are expecting two arguments the first one being a number and
the second being a list (of unlimited number of items), really all
functions described have an unlimited number of arguments but function g
packs all arguments but the first in a list.

I think I get the point, but what confuses me is when you say

On Sat, Jan 28, 2017 at 8:31 AM, Alexander Burger <a...@software-lab.de>
wrote:

> > From this point of view my question is about the difference of using or
> > > not using dot when describing a function, for example, take the if
> > > description:
> > >
> > > (if 'any1 any2 . prg) -> any
> > >
> > > Would the description below describe the same function?
> > >
> > > (if 'any1 any2 prg) -> any
>
> A typical call of 'if' could be
>
>    (if (testSomething) (doSomething1) (doSomething2) (doSomething3))
>
> where
>
>    any1 is the result of evaluating (testSomething)
>    any2 is (doSomething1)
>    prg is ((doSomething2) (doSomething3))
>
> Perhaps it helps understanding if we remember that
>
>    (if (testSomething) (doSomething1) (doSomething2) (doSomething3))
>
> is the same as
>
>    (if (testSomething) (doSomething1) . ((doSomething2) (doSomething3)))
>
>
> If 'if' were specified as in the second case (if 'any1 any2 prg), then we
> would
> need to call it as
>
>    (if (testSomething) (doSomething1) ((doSomething2) (doSomething3)))
>
> to match the spec (if 'any1 any2 prg) and get the same bindings.
>
>
but this also means the only way to indicate several executable expressions
in the "then-clause" is to surround them between parens, i.e.  (if (= 2 2)
((print "equal") (print "2")) (print "not equal") (print "not 2"))   I
appreciate here an absence of symmetry, you must pack all exe expressions
in a list for "then-clause" but you can't do it for "else-clause"  [in fact
I think it will fail if you do that in a "then-clause" like (if T 1 ((print
"ups") (print "error"))) ]

why not to define and describe function if in a symmetrical way as   (if
'any prg1 prg2)  even when not obeying parens economy?   (sure there is a
good reason to do it that way simply I'm not able to see)

this way you always write prgs inside a list whatever being in then-clause
or an else-clause   i.e.  (if (> a b) ((print "a greater")) ((print "b
greater or equal")))

>
> > > (if T 3 4)                                               #
> invalid because 4 is a number not a prg (a list)
>
> Yes, but the prg is (4), not 4.
>

I guess you say that because using the "stack" simil you used in previous
email, when you pop first item it remais (T 3 4) when you pop again it
remains (3 4) and with next pop which remains is (4)

I think my confusion is due to the lack of one more pop to get 4 rather
than (4) , if the answer is "because prg indicates its a list, if you want
to indicate a number you should use num instead" then my confusion is like
this:

- two functions f described this way:

(f num . lst)
(f num1 num2)

then the list (f 1 2) is a valid call for both functions, the first f will
bind first parameter to numer 1 and second parameter to list (2) (all
remaining parameters as a list) while the second f will bind 1 to num1 and
2 to num2 (descarding empty list NIL). My confusion here is picolisp must
do two pops to bind parameters for a first f function call but three pops
to bind parameters for a second f function call. How discriminate picolisp
between each cases? I suppose the answer is function definition:

first f defined as (de f (X . Rest) (...) )
second f defined as (de f (X Y) (...) )

is it ok?

thanks a lot and forgive my insistence ;-)
```