octave-maintainers
[Top][All Lists]
Advanced

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

Re: Overloading built-in function?


From: John W. Eaton
Subject: Re: Overloading built-in function?
Date: Wed, 18 Apr 2007 15:43:34 -0400

On 18-Apr-2007, Michael Goffioul wrote:

| Is there a workaround for this? The code I'm working on implements its
| own get/set methods (java-based). The inability to overload them is quite
| annoying.

Matlab has some interesting behavior with functions that overload
built-in functions.  For example, given a file sin.m (not in an @CLASS
directory, just somewhere in the path):

  function y = sin (x, y)
    disp ('Matlab is sinful');

then

  sin
  sin ('foo')
  sin ('foo', 'bar')
  sin ('foo', 2)

etc. all call the .m file version and

  sin (1)

calls the built-in function.  But

  sin (1, 2)
  sin (1, 'foo')

fail with a 'too many arguments' error.

So overloading seems closely tied to the way objects work, so I think
it will really only work the same in Octave when we have Matlab
compatible objects (which I am trying to work on now, but will not be
merged with the main CVS trunk until after 3.0 is released.

jwe
k


reply via email to

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