unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11782: 24.1; closure is not self-quoting
@ 2012-06-25 18:47 Christopher Schmidt
  2012-07-20 12:12 ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Christopher Schmidt @ 2012-06-25 18:47 UTC (permalink / raw)
  To: 11782

I am not exactly sure if this is a bug, a feature or something that is
just undefined.

    (funcall (eval (eval '(let ((var)) (lambda ())))))

works fine, whereas

    (funcall (eval (eval '(let ((lex-var)) (lambda ())) t)))

does not work.

Backtrace:

    Debugger entered--Lisp error: (void-function closure)
      (closure ((lex-var) t) nil)
      eval((closure ((lex-var) t) nil))
      (funcall (eval (eval (quote (let ((lex-var)) (lambda nil))) t)))
      eval((funcall (eval (eval (quote (let ((lex-var)) (lambda nil))) t))))

I am on GNU Emacs 24.1.1 (x86_64-unknown-linux-gnu, GTK+ Version
2.24.10).

        Christopher





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#11782: 24.1; closure is not self-quoting
  2012-06-25 18:47 bug#11782: 24.1; closure is not self-quoting Christopher Schmidt
@ 2012-07-20 12:12 ` Stefan Monnier
  2012-07-20 13:38   ` Christopher Schmidt
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2012-07-20 12:12 UTC (permalink / raw)
  To: 11782

>     (funcall (eval (eval '(let ((lex-var)) (lambda ())) t)))
> does not work.

Note that (eval (eval '(cons 1 2))) does not work either.
So I don't consider it a bug.


        Stefan





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#11782: 24.1; closure is not self-quoting
  2012-07-20 12:12 ` Stefan Monnier
@ 2012-07-20 13:38   ` Christopher Schmidt
  2013-02-23 14:53     ` Christopher Schmidt
  0 siblings, 1 reply; 8+ messages in thread
From: Christopher Schmidt @ 2012-07-20 13:38 UTC (permalink / raw)
  To: 11782

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

Thanks for your answer.

>>     (funcall (eval (eval '(let ((lex-var)) (lambda ())) t)))
>> does not work.
>
> Note that (eval (eval '(cons 1 2))) does not work either.
> So I don't consider it a bug.

That's true, of course.  Lambdas are an exception in Emacs Lisp and
CL, though.

    (info "(elisp)Lambda Expressions")

    In Emacs Lisp, such a list is valid as an expression--it evaluates
    to itself.  But its main use is not to be evaluated as an
    expression, but to be called as a function.

I stumbled upon this issue a few times already.  So did others.

    http://stackoverflow.com/questions/7913207/how-does-the-definition-for-apply-partially-work-in-emacs-24

IMO the info node I referenced above should mention this.

        Christopher





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#11782: 24.1; closure is not self-quoting
  2012-07-20 13:38   ` Christopher Schmidt
@ 2013-02-23 14:53     ` Christopher Schmidt
  2013-05-28 20:40       ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Christopher Schmidt @ 2013-02-23 14:53 UTC (permalink / raw)
  To: 11782

Ping?

(I think the issue I describe is a severe bug.)

        Christopher





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#11782: 24.1; closure is not self-quoting
  2013-02-23 14:53     ` Christopher Schmidt
@ 2013-05-28 20:40       ` Stefan Monnier
  2013-05-28 22:35         ` Christopher Schmidt
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2013-05-28 20:40 UTC (permalink / raw)
  To: 11782

> (I think the issue I describe is a severe bug.)

Could you expand on why you think it's severe?


        Stefan





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#11782: 24.1; closure is not self-quoting
  2013-05-28 20:40       ` Stefan Monnier
@ 2013-05-28 22:35         ` Christopher Schmidt
  2013-05-29  0:25           ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Christopher Schmidt @ 2013-05-28 22:35 UTC (permalink / raw)
  To: 11782

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

Hi Stefan,

> Could you expand on why you think it's severe?

I think this issue is severe because the behaviour is odd and follows
neither other mature Lispy languages nor the reference manual.

    (info "(elisp)Lambda Expressions")

    In Emacs Lisp, such a list is valid as an expression--it evaluates
    to itself.

As I said 11 month ago, I hit on this issue a few times already.  So did
others.  In most cases I had a lambda form that was eval'ed twice due to
macro expansion.

    ;; -*- lexical-binding: t -*-

    (defmacro a ()
      (let ((l (lambda () )))
        `(funcall ,l)))

    (a)

I realise there is a technical need for lambda's to evaluate to closures
in a lexical environment.  Are there any technical reasons for lexical
closures to not self-quote?

BTW I am perfectly fine with just fixing the docs.

        Christopher





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#11782: 24.1; closure is not self-quoting
  2013-05-28 22:35         ` Christopher Schmidt
@ 2013-05-29  0:25           ` Stefan Monnier
  2013-05-29  7:05             ` Christopher Schmidt
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2013-05-29  0:25 UTC (permalink / raw)
  To: 11782

>> Could you expand on why you think it's severe?
> I think this issue is severe because the behaviour is odd and follows
> neither other mature Lispy languages nor the reference manual.

I see.  So we just disagree on what is considered severe (I expected
something like "this and that common idiom found in those packages fails").

    In Emacs Lisp, such a list is valid as an expression--it evaluates
    to itself.

Clearly this doc needs to be fixed since it confuses lambda expressions
and lambda values and while this conflation mostly worked in dynamic
binding, it does not work any more in the presence of closures.  I just
installed the patch below.


        Stefan


--- doc/lispref/functions.texi	2013-01-01 09:11:05 +0000
+++ doc/lispref/functions.texi	2013-05-29 00:16:58 +0000
@@ -196,9 +196,8 @@
 @end example
 
 @noindent
-In Emacs Lisp, such a list is valid as an expression---it evaluates to
-itself.  But its main use is not to be evaluated as an expression, but
-to be called as a function.
+In Emacs Lisp, such a list is a valid expression which evaluates to
+a function object.
 
   A lambda expression, by itself, has no name; it is an @dfn{anonymous
 function}.  Although lambda expressions can be used this way






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#11782: 24.1; closure is not self-quoting
  2013-05-29  0:25           ` Stefan Monnier
@ 2013-05-29  7:05             ` Christopher Schmidt
  0 siblings, 0 replies; 8+ messages in thread
From: Christopher Schmidt @ 2013-05-29  7:05 UTC (permalink / raw)
  To: 11782-done

Stefan Monnier <monnier@iro.umontreal.ca> writes:
>     In Emacs Lisp, such a list is valid as an expression--it evaluates
>     to itself.
>
> Clearly this doc needs to be fixed since it confuses lambda
> expressions and lambda values and while this conflation mostly worked
> in dynamic binding, it does not work any more in the presence of
> closures.  I just installed the patch below.

Thanks a lot!

        Christopher





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-05-29  7:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-25 18:47 bug#11782: 24.1; closure is not self-quoting Christopher Schmidt
2012-07-20 12:12 ` Stefan Monnier
2012-07-20 13:38   ` Christopher Schmidt
2013-02-23 14:53     ` Christopher Schmidt
2013-05-28 20:40       ` Stefan Monnier
2013-05-28 22:35         ` Christopher Schmidt
2013-05-29  0:25           ` Stefan Monnier
2013-05-29  7:05             ` Christopher Schmidt

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).