[Top][All Lists]

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

Re: defining global values from C++ DLD-functions

From: Tim Piessens
Subject: Re: defining global values from C++ DLD-functions
Date: Mon, 3 Mar 2003 09:11:12 +0100 (MET)

On Sat, 1 Mar 2003, Paul Kienzle wrote:

> Tim Piessens wrote:
> >Hello,
> >
> >It seems that set_global_value() can be used to set a global value, but
> >I cannot find a function to define a global variable from a
> >dld-function. Does anyone have solution to do that ?
> >
> Did you try set_global_value()?  Looking at the
> code, it does global_sym_tab->lookup(name,true),
> which if I read the code for lookup correctly, means
> that a new symbol will be defined if it is not found.

This does not seem to be correct. I have tested this with the following
small example :

DEFUN_DLD(test, args, nargout, "Testing set_global_value() \n")

        return args(1);

This gave the following in octave :

octave --norc
octave:1> a
error: `a' undefined near line 1 column 1
octave:1> test("a",3)
ans = 3
octave:2> a
error: `a' undefined near line 2 column 1
octave:2> a=2
a = 2
octave:3> who

*** dynamically linked functions:


*** local user variables:


octave:4> global a
warning: local variable value may have changed to match global
octave:5> a
a = 3
octave:6> test("a",4)
ans = 4
octave:7> a
a = 4
octave:8> who

*** dynamically linked functions:


*** globally visible user variables:


So if I interpret correctly, set_global_value() does set "a" define a
but does not declare it.


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]