slang-users mailing list

[2006 Date Index] [2006 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] Implicit variable declarations


Michael Noble <mnoble@xxxxxxxxxxxxx> wrote:
>> variable x = [1:100:1];
>> newvar = @x;
>> is_defined("newvar");
>
>Then I believe this is a namespace issue.

Right.  Unless a namespace prefix is specified, `is_defined` searches
the "Global" namespace.  Variables that are automatically declared are
placed in the static namespace, which may be anonymous as in your
case.  The `is_defined` function will not search such namespaces.  If
you want to search the current namespace, which may be an
anonymous one, then use the `_apropos` function, e.g.,

   names = _apropos (current_namespace (), "^newvar$", 0xFF);

Also you might consider using __get_reference:

   if (NULL != __get_reference ("newvar"))
     {
       % newvar is defined
         .
	 .
     }

Thanks,
--John

_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2006 date index] [2006 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]