help-octave
[Top][All Lists]
Advanced

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

Re: Realtime cost of call by value


From: taltman
Subject: Re: Realtime cost of call by value
Date: Thu, 30 Oct 2003 10:11:10 -0800 (PST)

Well, drawing a parallel from the weakly-typed nature of variables in
the Octave interpreter, I believe that it should be possible to have
these references to all types. Every function needs to do input type
checking anyways, and whenever a new type is added to Octave, those
need to be updated as well, no?

Also, before this proceeds, I think there needs to be a clear
definition of scoping in Octave in *.oct files vs. M-files vs. the
interpreter. Otherwise, it can be very easy for things to run amok.

Thanks,

~Tomer


On Oct 30, 2003 at 9:41am, John W. Eaton wrote:

jwe >Date: Thu, 30 Oct 2003 09:41:10 -0600
jwe >From: John W. Eaton <address@hidden>
jwe >To: address@hidden
jwe >Cc: address@hidden
jwe >Subject: Re: Realtime cost of call by value
jwe >Resent-Date: Thu, 30 Oct 2003 09:41:11 -0600
jwe >Resent-From: address@hidden
jwe >
jwe >On 30-Oct-2003, Glenn Golden <address@hidden> wrote:
jwe >
jwe >| OK, well, in the spirit of monkeys with typewriters --  C++ compilers
jwe >| in this case, me being the monkeys -- I tried what you suggested, more
jwe >| or less verbatim.  Compilation of the DLD fails though, because in
jwe >| 
jwe >|     octave_value& val = get_global_reference(globname);
jwe >|     Matrix& a = val.matrix_reference();
jwe >| 
jwe >| there's no resolution for octave_value::matrix_reference().
jwe >| 
jwe >| Does there have to be a matrix_reference() method declared in the 
jwe >| octave_value base class in ov.h...? or something?
jwe >
jwe >Yes.  Look at the way the corresponding matrix_value function is
jwe >defined.
jwe >
jwe >| (I did add the public member def for matrix_reference() to ov-re-mat.h as
jwe >| 
jwe >|    Matrix& matrix_reference (void);
jwe >| 
jwe >| which seemed vaguely like the right thing to do.)
jwe >|     
jwe >| I also tried the dim-bulb workaround, casting it as
jwe >| 
jwe >|     Matrix& a = ((Matrix &)val).matrix_reference();
jwe >| 
jwe >| but then it segfaults doing the assignment to A(0,0), besides which I
jwe >| really have no clue if casting like this even makes any sense.
jwe >
jwe >Clearly, it does not.  If you find yourself writing a cast, something
jwe >is probably wrong.
jwe >
jwe >I'm still interested to know what people think about this feature.  Is
jwe >it something that would be useful?  If I see no feedback on that, then
jwe >I'll assume no one cares and I am unlikely to implement it.
jwe >
jwe >Better than just feedback, if someone would like to have this feature,
jwe >then perhaps they could implement it (with the CVS sources please,
jwe >because there have been lots of changes to the octave_value classes
jwe >recently).  It should not be that hard, most of what you need has been
jwe >posted to the list.  It would just require filling out the various
jwe >*_reference functions for all the octave_value subclasses.
jwe >
jwe >My only reservation about this is that it could lead to really ugly
jwe >code that looks like this:
jwe >
jwe >  if (ov.is_XXX)
jwe >    {
jwe >      XXX xxx = ov.XXX_reference ();
jwe >      // do something with xxx...
jwe >    }
jwe >  else if (ov.is_YYY)
jwe >    {
jwe >      YYY yyy = ov.YYY_reference ();
jwe >      // do something with yyy...
jwe >    }
jwe >  ...
jwe >
jwe >which is pretty bad form and can be hard to maintain (if someone adds
jwe >a new type, you have to go back to all the code that is written like
jwe >this and add new cases to handle them).
jwe >
jwe >But, maybe it would still be useful.
jwe >
jwe >jwe
jwe >
jwe >
jwe >
jwe >-------------------------------------------------------------
jwe >Octave is freely available under the terms of the GNU GPL.
jwe >
jwe >Octave's home on the web:  http://www.octave.org
jwe >How to fund new projects:  http://www.octave.org/funding.html
jwe >Subscription information:  http://www.octave.org/archive.html
jwe >-------------------------------------------------------------
jwe >
jwe >



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

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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