Why first lambda expression is args

Started by ssqq, July 06, 2015, 01:52:25 AM

Previous topic - Next topic

ssqq

I think first lambda expression should is 'lambda:



> (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

#1
Quote from: "ssqq"I think first lambda expression should is 'lambda:



> (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:

> (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:

> (li 3 4)

ERR: invalid list index
> (la 3 4)
7
>

From the manual http://www.newlisp.org/downloads/newlisp_manual.html#fn">//http://www.newlisp.org/downloads/newlisp_manual.html#fn:
Quote
... The fn or lambda word does not exist on its own as a symbol, but indicates a special list type: the lambda list. ...