emacs-devel
[Top][All Lists]
Advanced

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

Re: Distinguishing `consp` and `functionp`


From: Po Lu
Subject: Re: Distinguishing `consp` and `functionp`
Date: Sat, 27 Jan 2024 21:14:13 +0800
User-agent: Gnus/5.13 (Gnus v5.13)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> I've been annoyed at the use of lists to represent function values for
> a while now.  For a reason I cannot fathom, I even managed to reproduce
> that very same mistake in Emacs-24 with the `(closure ...)` value for
> statically scoped interpreted function values.
>
> That was a major blunder.
>
> In any case, I'm playing around with a "fix", making lambda evaluate
> (when interpreted) not to (lambda ...) or (closure ...) but to
> a self-evaluating value that can be more reliably distinguished.
> In the patch below, I just reused the #[...] byte-code objects for that,
> putting the function's body where the bytecode string goes and the
> function's captured environment where the "constant vector" goes.
>
> It's got several rough edges (most importantly that
> `byte-code-function-p` returns non-nil for interpreted function values),
> but it seems to work OK so far.
>
> You can't use the patch as-is because it's written against my local
> branch, with various local hacks, some of which (partly) remove support
> for lexical-binding==nil.
> But hopefully, it's readable enough for you to form an opinion.

I'm fine with it, on the condition that it continues to be possible to
print and read lambdas created by quoted function forms, as:

  #'(lambda () foo)

Needless to say, funcall should continue to accept old list lambdas,
whether functionp regards them as such or not.


reply via email to

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