News for hackers. Stuff that matters.
Re:Emacs Lisp Lambda Expressions Are Not Self-Evaluating by lispm on Friday February 23, 2018 @06:14AM (#16445618)
In Common Lisp:

a list (lambda () (print :foo)) is not code:

  CL-USER 10 > (let ((l '(lambda () (print :foo))))
                 (funcall l))
  
  Error: Argument to apply/funcall is not a function: (LAMBDA NIL (PRINT :FOO)).
But the unquoted lambda form is code, since Common Lisp has a LAMBDA macro

  CL-USER 13 > (let ((l (lambda () (print :foo))))
                 (funcall l))

  :FOO 
  :FOO
The LAMBDA macro transforms it into a FUNCTION special form with an embedded lambda expression:

  CL-USER 14 > (macroexpand-1 '(lambda () (print :foo)))
  (FUNCTION (LAMBDA NIL (PRINT :FOO)))
Thus in Common Lisp we can evaluate:

a) the special form FUNCTION:

  (FUNCTION (LAMBDA () (PRINT :FOO)))
b) the same, but using #' as a short version:

  #'(LAMBDA () (PRINT :FOO))
c) or the macro LAMBDA, which expands into a)

  (LAMBDA () (PRINT :FOO))
Re:Emacs Lisp Lambda Expressions Are Not Self-Evaluating by white-flame on Friday February 23, 2018 @07:33AM (#16445920)
One other combination in Common Lisp is that lambda expressions are usable as the head of a form, in place of a function name:

  ;; Call a function object held in a variable
  (let ((add (lambda (a b) (+ a b))))
    (funcall add 1 2))
vs

  ;; Direct execution of a lambda expression
  ((lambda (a b) (+ a b)) 1 2)
Macro expansion can place a literal or generated lambda expression there instead of using FUNCALL at all.
Re:Emacs Lisp Lambda Expressions Are Not Self-Evaluating by lisper on Friday February 23, 2018 @12:32PM (#16447787)
> Macro expansion can place a literal or generated lambda expression there instead of using FUNCALL at all.

Not quite. This, for example, does not work:

(defmacro foo () '(lambda (x) x))

((foo) 1)

A macro can expand into a form whose CAR is a literal lambda expression, but because there is always an equivalent LET form I can't think of a circumstance where this can do anything but obfuscate the code.

Personally, I think this is a flaw in the design of CL. Long ago I proposed an extension that would allow the CAR of a form to be a macro:

http://www.flownet.com/ron/lisp/combination-hook.lisp

I think it's cool for pedagogy because it lets you do things like directly define the Y combinator in CL without a ton of FUNCALLs. But it never caught on.

Re:Emacs Lisp Lambda Expressions Are Not Self-Evaluating by sillysaurus3 on Friday February 23, 2018 @07:51AM (#16445989)
That's not actually a limitation of emacs lisp. It's just a design decision.

I know exactly the spot in the code where they could do what you suggest, because I've often wondered why they don't.

elisp gets a bad rap. But it's mostly self-inflicted.

Also http://www.patrickkphillips.com/grammar/is-it-a-bad-rap-or-b...

A “rap sheet” is a criminal record, and a “bum rap” meant a false accusation (or even a false conviction). Even when the charge was valid, it should come as no surprise, a guilty party might claim it was a “bum rap” just to save face.

Had no idea what a bad rap actually meant.

Re:Emacs Lisp Lambda Expressions Are Not Self-Evaluating by microcolonel on Friday February 23, 2018 @08:20AM (#16446117)
It sure is lovely that a world has been created where most people don't even need to know what "rap sheet" means.
Re:Emacs Lisp Lambda Expressions Are Not Self-Evaluating by kazinator on Friday February 23, 2018 @10:02AM (#16446656)
I don't know if this is worth mentioning, but a lambda expression datum can be coerce-d into a function:

  (let ((l '(lambda () (print :foo))))
    (funcall (coerce l 'function)))
not to mention passed to eval or compile.