emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Distinguishing `consp` and `functionp`


From: João Távora
Subject: Re: Distinguishing `consp` and `functionp`
Date: Mon, 29 Jan 2024 16:34:06 +0000

On Mon, Jan 29, 2024 at 4:17 PM Andreas Schwab <schwab@suse.de> wrote:
>
> On Jan 29 2024, João Távora wrote:
>
> > I don't think there is much space for philosophy or debate in noting
> > for example, that a list as lambda won't get byte-compiled like a
> > true lambda form.
> >
> > (byte-compile '(let ((bla (lambda () (+ 42 42))))
> >                  (funcall bla))) ;; -> (byte-code "\300\211 \207" [#[0
> > "\300\207" [84] 1]] 2)
> >
> >
> > (byte-compile '(let ((bla '(lambda () (+ 42 42))))
> >                  (funcall bla)));; -> (byte-code "\300 \207" [(lambda
> > nil (+ 42 42))] 1)
>
> Functions should be quoted with function, not quote:
>
> ELISP> (byte-compile '(let ((bla #'(lambda () (+ 42 42)))) (funcall bla)))
> (byte-code "\300\211 \207"
>            [#f(compiled-function
>                ()
>                #<bytecode 0x1980001536a5>)]
>            2)


Of course, that's the point.  My point is that even

(let ((bla (list 'lambda nil '(+ 42 42))))
  (functionp bla))

will return t.

In fact even

   (functionp (cddr (list 'foo 'bar 'lambda 'baz))

returns t

Anyway lambda in particular doesn't need to be function-quoted though.
So there's no need to put the #' there if you want a proper function
object.

João



reply via email to

[Prev in Thread] Current Thread [Next in Thread]