[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Function environment table interface
- From: Doug Rogers <doug.rogers@...>
- Date: Mon, 06 Jul 2009 17:44:07 -0400
Peter Cawley wrote:
On Mon, Jul 6, 2009 at 9:20 PM, Rob Kendrick<firstname.lastname@example.org> wrote:
I just had a thought; why are function environments not implemented via
a field in a metatable? For example;
> Firstly, environment tables are per-function, whereas all functions
> share a single metatable, so function environments could not be set
> via metatable. Secondly, separating the environment from the metatable
> allows for one to be per-instance and one to be per-class.
It may be that OP meant also to ask "Why not a per-instance metatable
for functions?" If so, I'd recommend a fun journey through these threads:
IMHO, the short reply to the original question is "performance".
Requiring the attachment of a metatable for __env would levy the
overhead of a table lookup, possibly a chain of them due to __index, for
each function call.
I like the general direction you're going - unifying and generalizing -
but it seems that separate environments for functions are too useful for
such a price to be paid per call.
The information contained in this email transmission may contain proprietary and business
sensitive information. If you are not the intended recipient, you are hereby notified that
any review, dissemination, distribution or duplication of this communication is strictly
prohibited. Unauthorized interception of this e-mail is a violation of law. If you are not
the intended recipient, please contact the sender by reply email and immediately destroy all
copies of the original message.
Any technical data and/or information provided with or in this email may be subject to U.S.
export controls law. Export, diversion or disclosure contrary to U.S. law is prohibited.
Such technical data or information is not to be exported from the U.S. or given to any foreign
person in the U.S. without prior written authorization of Elbit Systems of America and the
appropriate U.S. Government agency.