On Thu, Jan 26, 2017 at 11:35:20PM +0100, pd wrote:
> Alex, thanks a lot for your very clarifier reply (specially the procedural
> way of thinking which makes a lot of sense to me), I'm still confusing in a
> couple of things...

No problem!

BTW, I thought again about the terminology of "list" versus "cons pairs" and
plain "cells". "list" is a rather unprecise term, I feel it is not limited to "a
chain of cells with NIL at the end". I use "list" for any sequence of cells (as
opposed to other structures like "tree", "graph" or "set"). These include also
e.g. "circular lists" like (1 2 3 .), which have no NIL at the end (in fact, no
end at all).

> I've read in docs that the ' prefix in a name of formal parameter when
> describing a funcion indicates it's a evaluated parameter  (even when the


> opposite is clearer to me , using ' to indicate a non-evaluated parameter
> following the quote notation you use when want to preserve something from
> evaluation)

That would also make sense. I think the notation in the docs mirrors *some*
typical call scenarios.

> but when describing functions ' is a notation mark with a
> semantic, what is the semantic of dot notation mark when used in formal
> parameters in function description?
> I mean, you have these two notations for functions:
>   -  (dbs+ 'num . lst)
>   -  (delete 'any 'lst) -> lst
> are they applied the same? with the same kind of parameters?

The functions behave differently. (dbs+ 'num . lst) means that the the function
takes an unlimited number of arguments, where only the first one is evaluated,
while (delete 'any 'lst) takes two evaluated arguments.

> So I suppose the notation (dbs+ 'num . lst) refers to a function defined as
> (de dbs+ X . Z ...) and thus first parameter is binded to X and also must

Yes, (de dbs+ (X . Z) ..) to be precise.

> evaluate to a number and rest of parameters will be bound to Z, so you call
> this function like (dbs+ 4 a b c) ,  what notation will you use to express
> you have to pass a list as parameter to a function?  maybe (dbs+ 'lst) ? I

These function definitions say nothing about the types of the arguments like
number, list etc. This is determined by the behavior of the function's body.

To indicate that an argument is *expected* to be a list, I usually use 'Lst'

   (de foo (Lst)

> mean a notation to express you *must* call a function using a list like (f
> (a b c)) and not (f a b c)

Note that (f (a b c)) does not mean that a list will be passed, but depends on
the return value of the function 'a'). Same for (f a b c), it depends on the
values of the symbols 'a', 'b', and 'c'.

There is no strict, static notation for the types of arguments to a function.
This is a dynamic issue.

> Also taking about dot, as you said you have to use delimiters to separate
> symbols and thus you must surround dot with spaces (or any other delimiter
> I suppose, probably you can write the weird sentence (a,.,b) as an
> alternative to (a . b) dotted pair), so I suppose dot is kind of operator
> (maybe a read macro as ' ?) anyway I think it would be interesting if dot

It is *similar* to a read macro, as it controls the behavior of the reader. I
would not call it a "macro", because it has no corresponding expanded or
evaluated representation, like:

   'abc     -> (quote . abc)
   `(* 3 4) -> 12

Instead, it is Lisp "syntax", on the same level as parentheses etc.

> could act as an operator being associative to the right, so you can write:
> ( a . b . c . d . NIL)
> to be equal to
> (a . (b . (c . (d . NIL))))
> and also equal to  (a b c d)
> does it have any sense?

It would be possible to change the reader to accept (a . b . c . d . NIL), but
I'm not sure at the moment. Would there be any advantage?

♪♫ Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to