octave-maintainers
[Top][All Lists]
Advanced

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

Re: anonymous functions optimization - wanted for 3.4.0?


From: Olaf Till
Subject: Re: anonymous functions optimization - wanted for 3.4.0?
Date: Fri, 10 Sep 2010 20:56:27 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

On Fri, Sep 10, 2010 at 11:52:44AM +0200, Jaroslav Hajek wrote:
> hi all,
> 
> attached is a patch that implements an interesting (IMHO) optimization
> of anonymous function handles. First a bit of theory:
> A number of anonymous function handles looks like this:
> 
> h = @(par1, par2, ...) some_func (arg1, arg2, ....)
> 
> where each argi is either a reference to some parj, or a constant, or
> a variable defined in the calling context. Such a function
> is called a "binder" because it merely takes some other function or
> handle and binds some of its parameters to certain values.
> Callback functions are often binders.
> 
> Examples:
> 
> @(x) size (x, 3)
> @(x, y) my_func (x, my_data, y)
> 
> The attached patch optimizes calls to binders. When Octave constructs
> an anonymous handle, it attempts to detect if it's a binder. If so, it
> augments the handle with information how to transform the argument
> list and the "root" function's handle (or value). It then overrides
> the call sequence with a fast code that transforms the argument list
> and calls the root function. This eliminates the overhead of setting
> up an m-function, altering the call stack, and interpreting the
> function's body, making binders only incur small additive penalty to
> the root function's cost.

If somewhere in a stack of "binders" occurs an error (reference to a
missing argument), will the error message show in which "binder" the
error occurs? Olaf


reply via email to

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