emacs-devel
[Top][All Lists]
Advanced

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

Re: User-reserved element in byte code vectors


From: Stefan Monnier
Subject: Re: User-reserved element in byte code vectors
Date: 28 Apr 2004 13:12:50 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>> I'd argue that the closure's enviornment should be put as the first
>> element in the constants-vector rather than in a separate slot in
>> the byte code object: it makes closure construction slower and more
>> clostly, but it makes the function call faster (it's just a normal
>> function call and you can access the closure's vars directly from
>> the byte code without explicitly passing them as an extra argument).

> Yes, that would be nice.  What I do right now is actually conceptually
> like

>         (defun make-closure (fn env)
>           (byte-compile
>             `(lambda (&rest args)
>                (let ((env ,env))
>                  (apply ,fn args)))))
             
> (but more optimized) which makes the environment end up in the
> constants vector.

Right, but in the constants-vector if the wrapper function used for the
closure, whereas I was thinking of removing the indirection and do
something more like

   (defun make-closure (env args bytes csts &rest rest)
     (apply 'make-byte-code args bytes (vconcat (vector env) csts) rest))

> I guess a very extensible scheme would be to create a new function
> allocate-byte-code-element which returnes an index to a byte code
> vector element which can be used for any purpose the caller likes, but
> then, is the complexity (though small) worth it?

I think it's way overkill.


        Stefan




reply via email to

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