[Top][All Lists]

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

Re: overloading functions (Was: Indirect Addressing Question)

From: Paul Kienzle
Subject: Re: overloading functions (Was: Indirect Addressing Question)
Date: Fri, 16 Nov 2001 11:15:46 -0500

address@hidden wrote:

> On Wed, 14 Nov 2001, Paul Kienzle wrote:
> > Anyone want to take a shot at modifying the interpreter so that you can
> > overload functions for user-defined types?
> This would be a _good thing_.
> My suspicion is that this would be hard. You really need
> quite a lot of OO infrastructure to this king of
> function overloading. Matlab syntax and semantics don't
> support this king of stuff.
> I would really like this feature though, maybe someone can
> think of a way to make it work.

Matlab decides what function to call based on the type of the
first argument, which can be done reasonably cheaply and
handles the majority of the cases.  It wouldn't handle the case
for example of filtering a sparse vector where the first argument
is a full vector of coefficients.

You could extend this so that if any of the arguments were of
a user defined type, then check for a type specific function, but
that won't scale well if there are a lot of user defined types

You could have a list of specific cases that you need to check
for attached to each function object.  For example, the entry
for filter might look like:
    <any> <any> sparse  -> spfilter
but this is too expensive to check for on every call to every
function. We could define a new type of function object called
function_dispatch so that only the functions which need to be
dispatched have to pay for it.  We might even be able to do
this as a user-defined type so that octave would not have
to change.  The only caveat is that you would need to register
all of your functions when you initialize your type, even those
that are in script files.

Paul Kienzle

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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