Re: Examples of quote usage instead of lambda

2020-02-06 Thread John Duncan
Thanks, and I probably should have said, "car and cdr of a cell" rather
than a list. Oh well ;)

On Thu, Feb 6, 2020 at 1:16 PM Alexander Burger  wrote:

> On Thu, Feb 06, 2020 at 12:41:51PM -0500, John Duncan wrote:
> > Yeah, it's explained in the reference manual:
> > ...
> > In contrast to other Lisp implementations, the symbol LAMBDA itself does
> > not exist in PicoLisp but is implied from context.
> > ...
> > Hope this helps a bit. Alex would probably have a lot more to say.
>
> Thanks John! No, you explained it very well :)
>
>
> One minor note:
>
> > Picolisp is dynamically scoped.
>
> I would not use the term "scoped" here. Scope is about visibility, so
> PicoLisp
> symbols are globally scoped (per namespace, or per file for transient
> symbols).
>
> Instead, symbols in PicoLisp are *bound* dynamically (as opposed to
> statically
> (or lexically) bound symbols in compiled Lisps). In a compiler, the
> distinction
> between scope and binding is blurred, because the symbols are gone in the
> compiled code anyway.
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


-- 
John Duncan


Re: Examples of quote usage instead of lambda

2020-02-06 Thread Grant Shangreaux
> but this can't be made to work in a Common Lisp--or can it and I'm just not 
> doing it right? As I understand it, you have a different sort of quote than 
> CL, correct?

You can't write a lambda expression like that in Common Lisp, but as far as I 
know the quote function is the same. I guess it seems slightly different:

Picolisp:

: (quote (X Y) (+ X Y))
-> ((X Y) (+ X Y))

To get the same result in Common Lisp you have to use an extra set of parens:

* (quote ((X Y) (+ X Y)))
((X Y) (+ X Y))

Otherwise you get a wrong number of arguments error.

> (quote . any) -> any
> Returns any unevaluated
>
> What does the dotted cons notation mean?

I think the key take away of this for me is that EVERYTHING in PicoLisp is made 
out of cells. So you can express a type this way, any cell with quote in its 
car will return the entire cdr of the cell no matter what it is.

Re: Examples of quote usage instead of lambda

2020-02-06 Thread Wilhelm Fitzpatrick



On 2/6/20 9:41 AM, John Duncan wrote:

The dotted pair syntax (a . b) refers to the car and cdr of a list.


I too had been scratching my head about the use of the dotted notation 
in the function documentation, but I just had a lightbulb. Since in a 
regular list, the cdr is the "tail", in an example like:


(let? sym 'any . prg)

..the dot is telling us that "prg" represents the "rest of the list" 
i.e. all the expressions that follow the (in this case) first three 
elements.


Thank you for your explanation, John.

-wilhelm


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


Re: Examples of quote usage instead of lambda

2020-02-06 Thread Alexander Burger
On Thu, Feb 06, 2020 at 12:41:51PM -0500, John Duncan wrote:
> Yeah, it's explained in the reference manual:
> ... 
> In contrast to other Lisp implementations, the symbol LAMBDA itself does
> not exist in PicoLisp but is implied from context.
> ... 
> Hope this helps a bit. Alex would probably have a lot more to say.

Thanks John! No, you explained it very well :)


One minor note:

> Picolisp is dynamically scoped.

I would not use the term "scoped" here. Scope is about visibility, so PicoLisp
symbols are globally scoped (per namespace, or per file for transient symbols).

Instead, symbols in PicoLisp are *bound* dynamically (as opposed to statically
(or lexically) bound symbols in compiled Lisps). In a compiler, the distinction
between scope and binding is blurred, because the symbols are gone in the
compiled code anyway.

☺/ A!ex

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


Re: Examples of quote usage instead of lambda

2020-02-06 Thread Alexander Burger
Hi Lawrence,

> I've been a passive observer for a while, but now I'm really trying to grok
> picolisp.

Welcome! :)

> So let's start with the FAQ bit about *I cannot find the LAMBDA
> keyword in PicoLisp. *The example is basically syntax sugar for
> 
> ((quote (X Y) (+ X Y)) 3 4)
> 
> but this can't be made to work in a Common Lisp--or can it and I'm just not
> doing it right?

'quote' cannot be used in Common Lisp that way. It works in PicoLisp, because of
the equivalence if code and data. The list ((X Y) (+ X Y)) is a function in
PicoLisp, and the expression (quote (X Y) (+ X Y)) returns that list.


> As I understand it, you have a different sort of quote than
> CL, correct?

Yes. All other Lisps I know of follow the syntax (quote any), i.e. 'quote' is a
function which takes a *single* argument and returns it unevaluated. What they 
do
is taking the CADR of (quote any), resulting in 'any'.

PicoLisp, on the other hand, follows the synax

> *(quote . any) -> any*

This means,it takes the CDR, resulting in 'any'.

So (quote a b c) - which is (quote . (a b c)) - returns (a b c).


> What does the dotted cons notation mean? I know I have to lengthen my

It is the notation for a cell, separating CAR and CDR. So in PicoLisp,
(quote . a) is a single cell, while in other Lisps you need (quote a) which is
(quote . (a)), which takes two cells.


> comp-sci stride to grok picolisp, but I might be here with a lot of newbie
> questions for a while. . . .

No problem! Please don't hesitate to ask! :)

☺/ A!ex

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


Re: Examples of quote usage instead of lambda

2020-02-06 Thread John Duncan
Yeah, it's explained in the reference manual:

https://software-lab.de/doc/ref.html#ev

Picolisp's evaluation strategy treats any list as a function to be
interpreted. If first element of the list evaluates to a lambda expression,
that is interpreted as a function.

a *lambda expression*. A lambda expression is a list, whose CAR is either a
symbol or a list of symbols, and whose CDR is a list of expressions. Note:
In contrast to other Lisp implementations, the symbol LAMBDA itself does
not exist in PicoLisp but is implied from context.

A lambda function would be a no-op in picolisp because there is no
compiling or creation of closures. Picolisp is dynamically scoped.

The dotted pair syntax (a . b) refers to the car and cdr of a list. if a
and b are both atoms, (a . b) is a list whose cdr is an atom. The list (a
b) can be represented as (a . (b . NIL).

So, (quote a) gives you a, (quote (a)) gives you (a).

Hope this helps a bit. Alex would probably have a lot more to say.

John

On Thu, Feb 6, 2020 at 12:20 PM Lawrence Bottorff  wrote:

> I've been a passive observer for a while, but now I'm really trying to
> grok picolisp. So let's start with the FAQ bit about *I cannot find the
> LAMBDA keyword in PicoLisp. *The example is basically syntax sugar for
>
> ((quote (X Y) (+ X Y)) 3 4)
>
> but this can't be made to work in a Common Lisp--or can it and I'm just
> not doing it right? As I understand it, you have a different sort of quote
> than CL, correct? Could you explain or point me to the docs on that? Also,
> when I looked up quote in the ref I see this
>
> *(quote . any) -> any*
> Returns any unevaluated
>
> What does the dotted cons notation mean? I know I have to lengthen my
> comp-sci stride to grok picolisp, but I might be here with a lot of newbie
> questions for a while. . . .
>
> Thanks,
> Lawrence Bottorff
> Grand Marais, MN, USA
>


-- 
John Duncan


Examples of quote usage instead of lambda

2020-02-06 Thread Lawrence Bottorff
I've been a passive observer for a while, but now I'm really trying to grok
picolisp. So let's start with the FAQ bit about *I cannot find the LAMBDA
keyword in PicoLisp. *The example is basically syntax sugar for

((quote (X Y) (+ X Y)) 3 4)

but this can't be made to work in a Common Lisp--or can it and I'm just not
doing it right? As I understand it, you have a different sort of quote than
CL, correct? Could you explain or point me to the docs on that? Also, when
I looked up quote in the ref I see this

*(quote . any) -> any*
Returns any unevaluated

What does the dotted cons notation mean? I know I have to lengthen my
comp-sci stride to grok picolisp, but I might be here with a lot of newbie
questions for a while. . . .

Thanks,
Lawrence Bottorff
Grand Marais, MN, USA