Why first lambda expression is args

Pondering the philosophy behind the language
Locked
ssqq
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

Why first lambda expression is args

Post by ssqq »

I think first lambda expression should is 'lambda:

Code: Select all

> (first (lambda (x y) (+ x y)))
lambda
> (first (fn (x y) (+ x y)))
fn
> 'lambda
lambda
> 'fn
fn
> (cons 'fn '((x y) (+ x y)))
(fn (x y) (+ x y))
Why newLISP use args as first elements of lambda expression?
Why could not quote *lambda* and *fn*?

hartrock
Posts: 136
Joined: Wed Aug 07, 2013 9:37 pm

Re: Why first lambda expression is args

Post by hartrock »

ssqq wrote:I think first lambda expression should is 'lambda:

Code: Select all

> (first (lambda (x y) (+ x y)))
lambda
> (first (fn (x y) (+ x y)))
fn
> 'lambda
lambda
> 'fn
fn
> (cons 'fn '((x y) (+ x y)))
(fn (x y) (+ x y))
Why newLISP use args as first elements of lambda expression?
Why could not quote *lambda* and *fn*?
lambda is a property of a list, and not a symbol at its beginning; an example:

Code: Select all

> (set 'li (cons '(x y) (cons '(+ x y) '())))
((x y) (+ x y))
> (first li)
(x y)
> (set 'la (cons '(x y) (cons '(+ x y) '(lambda))))
(lambda (x y) (+ x y))
> (first la)
(x y)
> 
-> both list and lambda list having (x y) as first element.
But only the lambda list works as function:

Code: Select all

> (li 3 4)

ERR: invalid list index
> (la 3 4)
7
>
From the manual http://www.newlisp.org/downloads/newlisp_manual.html#fn:
... The fn or lambda word does not exist on its own as a symbol, but indicates a special list type: the lambda list. ...

Locked