* Does not byte-compile return the compiled function in Emacs 24?
@ 2011-12-07 0:38 Lennart Borgman
2011-12-07 0:51 ` Juanma Barranquero
2011-12-07 1:36 ` Stefan Monnier
0 siblings, 2 replies; 14+ messages in thread
From: Lennart Borgman @ 2011-12-07 0:38 UTC (permalink / raw)
To: Emacs-Devel devel
It used to do that before. Is there any variable holding the newly
byte-compiled function?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 0:38 Does not byte-compile return the compiled function in Emacs 24? Lennart Borgman
@ 2011-12-07 0:51 ` Juanma Barranquero
2011-12-07 4:24 ` Kevin Rodgers
2011-12-07 1:36 ` Stefan Monnier
1 sibling, 1 reply; 14+ messages in thread
From: Juanma Barranquero @ 2011-12-07 0:51 UTC (permalink / raw)
To: Lennart Borgman; +Cc: Emacs-Devel devel
> It used to do that before.
It wasn't documented, was it?
> Is there any variable holding the newly
> byte-compiled function?
A function, as before:
(symbol-function 'my-func)
Juanma
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 0:51 ` Juanma Barranquero
@ 2011-12-07 4:24 ` Kevin Rodgers
2011-12-07 4:38 ` Lennart Borgman
0 siblings, 1 reply; 14+ messages in thread
From: Kevin Rodgers @ 2011-12-07 4:24 UTC (permalink / raw)
To: emacs-devel
On 12/6/11 5:51 PM, Juanma Barranquero wrote:
>> It used to do that before.
>
> It wasn't documented, was it?
It is the obvious, sensible value to return.
>> Is there any variable holding the newly
>> byte-compiled function?
>
> A function, as before:
>
> (symbol-function 'my-func)
As Lennart points out, that does not cover lambda forms.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 4:24 ` Kevin Rodgers
@ 2011-12-07 4:38 ` Lennart Borgman
2011-12-07 4:53 ` Kevin Rodgers
0 siblings, 1 reply; 14+ messages in thread
From: Lennart Borgman @ 2011-12-07 4:38 UTC (permalink / raw)
To: Kevin Rodgers; +Cc: emacs-devel
On Wed, Dec 7, 2011 at 05:24, Kevin Rodgers <kevin.d.rodgers@gmail.com> wrote:
> On 12/6/11 5:51 PM, Juanma Barranquero wrote:
>>>
>>> It used to do that before.
>>
>>
>> It wasn't documented, was it?
>
>
> It is the obvious, sensible value to return.
>
>
>>> Is there any variable holding the newly
>>> byte-compiled function?
>>
>>
>> A function, as before:
>>
>> (symbol-function 'my-func)
>
>
> As Lennart points out, that does not cover lambda forms.
I agree with Kevin, of course.
I just tried adding a name:
(byte-compile '(defun my-name () ...))
To my surprise the symbol my-name is not a function after this.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 4:38 ` Lennart Borgman
@ 2011-12-07 4:53 ` Kevin Rodgers
0 siblings, 0 replies; 14+ messages in thread
From: Kevin Rodgers @ 2011-12-07 4:53 UTC (permalink / raw)
To: Lennart Borgman; +Cc: emacs-devel
On Tue, Dec 6, 2011 at 9:38 PM, Lennart Borgman
<lennart.borgman@gmail.com> wrote:
> I just tried adding a name:
>
> (byte-compile '(defun my-name () ...))
>
> To my surprise the symbol my-name is not a function after this.
Shouldn't that be (without the quote):
(byte-compile (defun my-name () ...))
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 0:38 Does not byte-compile return the compiled function in Emacs 24? Lennart Borgman
2011-12-07 0:51 ` Juanma Barranquero
@ 2011-12-07 1:36 ` Stefan Monnier
2011-12-07 1:54 ` Lennart Borgman
2011-12-07 22:34 ` Johan Bockgård
1 sibling, 2 replies; 14+ messages in thread
From: Stefan Monnier @ 2011-12-07 1:36 UTC (permalink / raw)
To: Lennart Borgman; +Cc: Emacs-Devel devel
> It used to do that before. Is there any variable holding the newly
> byte-compiled function?
Don't know. `byte-compile' does various things in various circumstances
(it's pretty DWIMish), so without more details I can't help you.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 1:36 ` Stefan Monnier
@ 2011-12-07 1:54 ` Lennart Borgman
2011-12-07 9:12 ` Andreas Schwab
2011-12-07 15:12 ` Stefan Monnier
2011-12-07 22:34 ` Johan Bockgård
1 sibling, 2 replies; 14+ messages in thread
From: Lennart Borgman @ 2011-12-07 1:54 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Emacs-Devel devel
On Wed, Dec 7, 2011 at 02:36, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> It used to do that before. Is there any variable holding the newly
>> byte-compiled function?
>
> Don't know. `byte-compile' does various things in various circumstances
> (it's pretty DWIMish), so without more details I can't help you.
In mumamo.el I am building functions for fontification. I compile them
like this:
(setq byte-compiled-fun (let ((major-syntax-table))
(byte-compile fetch-func-definition)))
Previously it returned the byte-compiled function, but now it seems to
return t. (Or, at least it did not when I tested.)
I am using an anonymous function, but I think I can switch to a named
temporary function instead. I will try that.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 1:54 ` Lennart Borgman
@ 2011-12-07 9:12 ` Andreas Schwab
2011-12-07 15:12 ` Stefan Monnier
1 sibling, 0 replies; 14+ messages in thread
From: Andreas Schwab @ 2011-12-07 9:12 UTC (permalink / raw)
To: Lennart Borgman; +Cc: Stefan Monnier, Emacs-Devel devel
Lennart Borgman <lennart.borgman@gmail.com> writes:
> In mumamo.el I am building functions for fontification. I compile them
> like this:
>
> (setq byte-compiled-fun (let ((major-syntax-table))
> (byte-compile fetch-func-definition)))
>
> Previously it returned the byte-compiled function, but now it seems to
> return t. (Or, at least it did not when I tested.)
Works for me.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 1:54 ` Lennart Borgman
2011-12-07 9:12 ` Andreas Schwab
@ 2011-12-07 15:12 ` Stefan Monnier
2011-12-07 16:34 ` Lennart Borgman
1 sibling, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2011-12-07 15:12 UTC (permalink / raw)
To: Lennart Borgman; +Cc: Emacs-Devel devel
>>> It used to do that before. Is there any variable holding the newly
>>> byte-compiled function?
>> Don't know. `byte-compile' does various things in various circumstances
>> (it's pretty DWIMish), so without more details I can't help you.
> In mumamo.el I am building functions for fontification. I compile them
> like this:
> (setq byte-compiled-fun (let ((major-syntax-table))
> (byte-compile fetch-func-definition)))
This just tells me you call the function with some value and the get
the result. I.e. not much more information.
The key is to know what kind of value is passed to byte-compile: is it
a symbol, an arbitrary Lisp expression, a lambda expression, ...
> Previously it returned the byte-compiled function, but now it seems to
> return t. (Or, at least it did not when I tested.)
ELISP> (byte-compile '(lambda (x) (+ x 1)))
#[(x)
"\bT\207"
[x]
1]
ELISP>
> I am using an anonymous function, but I think I can switch to a named
> temporary function instead. I will try that.
If it's a lambda expression, I can't reproduce the problem, as
shown above.
BTW, C-u C-M-x in byte-compile and then single-stepping in this function
should quickly tell you the reason for what you see (unless there's
some defadvice at play, of course).
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 15:12 ` Stefan Monnier
@ 2011-12-07 16:34 ` Lennart Borgman
2011-12-09 2:12 ` Lennart Borgman
0 siblings, 1 reply; 14+ messages in thread
From: Lennart Borgman @ 2011-12-07 16:34 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Emacs-Devel devel
On Wed, Dec 7, 2011 at 16:12, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>>> It used to do that before. Is there any variable holding the newly
>>>> byte-compiled function?
>>> Don't know. `byte-compile' does various things in various circumstances
>>> (it's pretty DWIMish), so without more details I can't help you.
>> In mumamo.el I am building functions for fontification. I compile them
>> like this:
>> (setq byte-compiled-fun (let ((major-syntax-table))
>> (byte-compile fetch-func-definition)))
>
> This just tells me you call the function with some value and the get
> the result. I.e. not much more information.
> The key is to know what kind of value is passed to byte-compile: is it
> a symbol, an arbitrary Lisp expression, a lambda expression, ...
It is a lisp expression, but a big one. I am building a function to
call before fontification. This function let binds relevant variables
for the fontification.
When testing a bit more I see that (byte-compile (lambda ...)) returns
the function when everything goes ok, but not when there is an error.
For the function for php-mode fontification I get an error during byte
compilation:
Error: Wrong type argument: number-or-marker-p, nil
So it looks like byte-compile dislikes something in the (lambda ...)
for php-mode fontification. I just wished I knew what it is... ;-)
Perhaps someone has an idea of how to catch it? I build the let-list
with entries like
(list 'font-lock-syntactic-face-function (custom-quote
font-lock-syntactic-face-function))
Could this go wrong for some values?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 16:34 ` Lennart Borgman
@ 2011-12-09 2:12 ` Lennart Borgman
2011-12-09 2:57 ` Stefan Monnier
0 siblings, 1 reply; 14+ messages in thread
From: Lennart Borgman @ 2011-12-09 2:12 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Emacs-Devel devel
On Wed, Dec 7, 2011 at 17:34, Lennart Borgman <lennart.borgman@gmail.com> wrote:
>>> In mumamo.el I am building functions for fontification. I compile them
>>> like this:
>>> (setq byte-compiled-fun (let ((major-syntax-table))
>>> (byte-compile fetch-func-definition)))
>>
>> This just tells me you call the function with some value and the get
>> the result. I.e. not much more information.
>> The key is to know what kind of value is passed to byte-compile: is it
>> a symbol, an arbitrary Lisp expression, a lambda expression, ...
>
> It is a lisp expression, but a big one. I am building a function to
> call before fontification. This function let binds relevant variables
> for the fontification.
>
> When testing a bit more I see that (byte-compile (lambda ...)) returns
> the function when everything goes ok, but not when there is an error.
> For the function for php-mode fontification I get an error during byte
> compilation:
>
> Error: Wrong type argument: number-or-marker-p, nil
>
> So it looks like byte-compile dislikes something in the (lambda ...)
> for php-mode fontification. I just wished I knew what it is... ;-)
I am beginning to think that it is the size of the code for the
(lambda ...) that is the problem. When I delete some lines at least
byte-compile returns the function and I do not get the error above.
The size of the text code is some 230 000 characters (including white
space). The reason that it is so big is probably the syntax tables
copied, like this for example:
(list 'font-lock-syntax-table (custom-quote font-lock-syntax-table))
Including this in some way was necessary for fontification: ;; See
nXhtml bug 400415
Perhaps I should just make a local copy of the syntax table instead... hm...
That requires a bit of work. There are some more syntax tables too.
Any thoughts or ideas on this?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 1:36 ` Stefan Monnier
2011-12-07 1:54 ` Lennart Borgman
@ 2011-12-07 22:34 ` Johan Bockgård
2011-12-08 14:56 ` Stefan Monnier
1 sibling, 1 reply; 14+ messages in thread
From: Johan Bockgård @ 2011-12-07 22:34 UTC (permalink / raw)
To: emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
> Don't know. `byte-compile' does various things in various circumstances
> (it's pretty DWIMish), so without more details I can't help you.
What about this?
(byte-compile (defun foo ())) => #[...]
(byte-compile (lambda () nil)) => #[...]
(setq lexical-binding t)
(byte-compile (defun foo ())) => nil
(byte-compile (lambda () nil)) => nil
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Does not byte-compile return the compiled function in Emacs 24?
2011-12-07 22:34 ` Johan Bockgård
@ 2011-12-08 14:56 ` Stefan Monnier
0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2011-12-08 14:56 UTC (permalink / raw)
To: emacs-devel
>> Don't know. `byte-compile' does various things in various circumstances
>> (it's pretty DWIMish), so without more details I can't help you.
> What about this?
> (byte-compile (defun foo ())) => #[...]
This is really:
(defun foo ())
(byte-compile 'foo)
> (byte-compile (lambda () nil)) => #[...]
This happens to be the same as
(byte-compile '(lambda () nil))
which is the preferred form to call it.
> (setq lexical-binding t)
> (byte-compile (defun foo ())) => nil
Indeed, this is not supported currently: (symbol-function 'foo) is
a closure rather than a lambda expression, and byte-compile doesn't know
how to compile a closure.
> (byte-compile (lambda () nil)) => nil
This fails because you're passing it a closure rather than
a lambda-expression (i.e. same problem as for `defun' above).
This works: (byte-compile '(lambda () nil))
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-12-09 2:57 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-07 0:38 Does not byte-compile return the compiled function in Emacs 24? Lennart Borgman
2011-12-07 0:51 ` Juanma Barranquero
2011-12-07 4:24 ` Kevin Rodgers
2011-12-07 4:38 ` Lennart Borgman
2011-12-07 4:53 ` Kevin Rodgers
2011-12-07 1:36 ` Stefan Monnier
2011-12-07 1:54 ` Lennart Borgman
2011-12-07 9:12 ` Andreas Schwab
2011-12-07 15:12 ` Stefan Monnier
2011-12-07 16:34 ` Lennart Borgman
2011-12-09 2:12 ` Lennart Borgman
2011-12-09 2:57 ` Stefan Monnier
2011-12-07 22:34 ` Johan Bockgård
2011-12-08 14:56 ` Stefan Monnier
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).