help-octave
[Top][All Lists]
Advanced

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

Re: invoking java from within octave and do overloading


From: Ernst Reissner
Subject: Re: invoking java from within octave and do overloading
Date: Sun, 31 Oct 2010 20:54:24 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

Dear Michael,
thank you, you solved all problems i had but one: accessing octave_java with operators +-*/ and so on.

Greetings,
Ernst

On Sun, Oct 31, 2010 at 3:09 PM, Ernst Reissner <address@hidden> wrote:
  
Could you report the error you are seeing and a piece of code to reproduce
your
problem? It should work the same. For instance, is XFPNumber variable
accessible
from your constructor function?


Yes, the message was:

octave:1> l2r(0.4)
error: `XFPNumber' undefined near line 7 column 9
error: called from:
error:   /usr/share/octave/3.2.4/m/left2right/l2r.m at line 7, column 7
    
[snip]
  
##XFPNumber =
java_get('eu.simuline.arithmetics.left2right.XFPNumber','ONE');
XFPNumber = java_invoke('eu.simuline.arithmetics.left2right.XFPNumber',
                        'atomic',
                         java_new('java.lang.Double',2.5));

I thought, octaverc was invoked quite early.
    

The problem is that global variables are not visible within a function.
You should use the global keyword to make your function access
global XFPNumber.

  
Note also that if you overload the + operator that way (assuming it
works ok, I'm not 100% sure you can overload standar operators
with dispatch), this will use your lr_plus function for *any* octave_java
object.


Yes, this is exactly the problem.
I do not want this.
I would like to dispatch separately for lr-arithmetics, interval
arithmetics, bigdecimal arithmetics and all others.

How can i do this?
Can you tell me where to look up the class octave_java?
    

The "dispatch" method only works at octave level, for different type of
octave objects. From the octave point of view, *all* java objects are of
the same octave-internal type "octave_java". So the only thing that you
can do at octave-level is to dispatch the + operator for all java objects.

But nothing prevents you from using java polymorphism to continue
the dispatching at java-level.

Michael.

  


reply via email to

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