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: John W. Eaton
Subject: Re: Realtime cost of call by value
Date: Thu, 30 Oct 2003 09:41:10 -0600

On 30-Oct-2003, Glenn Golden <address@hidden> wrote:

| OK, well, in the spirit of monkeys with typewriters --  C++ compilers
| in this case, me being the monkeys -- I tried what you suggested, more
| or less verbatim.  Compilation of the DLD fails though, because in
| 
|     octave_value& val = get_global_reference(globname);
|     Matrix& a = val.matrix_reference();
| 
| there's no resolution for octave_value::matrix_reference().
| 
| Does there have to be a matrix_reference() method declared in the 
| octave_value base class in ov.h...? or something?

Yes.  Look at the way the corresponding matrix_value function is
defined.

| (I did add the public member def for matrix_reference() to ov-re-mat.h as
| 
|    Matrix& matrix_reference (void);
| 
| which seemed vaguely like the right thing to do.)
|     
| I also tried the dim-bulb workaround, casting it as
| 
|     Matrix& a = ((Matrix &)val).matrix_reference();
| 
| but then it segfaults doing the assignment to A(0,0), besides which I
| really have no clue if casting like this even makes any sense.

Clearly, it does not.  If you find yourself writing a cast, something
is probably wrong.

I'm still interested to know what people think about this feature.  Is
it something that would be useful?  If I see no feedback on that, then
I'll assume no one cares and I am unlikely to implement it.

Better than just feedback, if someone would like to have this feature,
then perhaps they could implement it (with the CVS sources please,
because there have been lots of changes to the octave_value classes
recently).  It should not be that hard, most of what you need has been
posted to the list.  It would just require filling out the various
*_reference functions for all the octave_value subclasses.

My only reservation about this is that it could lead to really ugly
code that looks like this:

  if (ov.is_XXX)
    {
      XXX xxx = ov.XXX_reference ();
      // do something with xxx...
    }
  else if (ov.is_YYY)
    {
      YYY yyy = ov.YYY_reference ();
      // do something with yyy...
    }
  ...

which is pretty bad form and can be hard to maintain (if someone adds
a new type, you have to go back to all the code that is written like
this and add new cases to handle them).

But, maybe it would still be useful.

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]