help-octave
[Top][All Lists]
Advanced

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

exist gotcha? (was Re: Re: How to tell a function from a string)


From: John W. Eaton
Subject: exist gotcha? (was Re: Re: How to tell a function from a string)
Date: Tue, 20 Jan 1998 22:32:05 -0600

On 20-Jan-1998, Jonathan King <address@hidden> wrote:

| I see one other "gotcha", as suggested by the following octave session:
| 
| mk26:~/matlab> octave
| Octave, version 2.0.9 (i586-pc-linux-gnu).
| Copyright (C) 1996, 1997 John W. Eaton.
| This is free software with ABSOLUTELY NO WARRANTY.
| For details, type `warranty'.
| 
| octave.bin:1> exist("who")  % this will return 5, like it should
| ans = 5
| octave.bin:2> % here's a stupid typo and its parse error
| octave.bin:2> exist(who)
| parse error:
| 
| >>> exist(who)
|              ^
| 
| octave.bin:2> exist("who")  % now this will fail...
| ans = 0
| octave.bin:3> who           % until you use it correctly...
| octave.bin:4> exist("who")  % and now it works again
| ans = 5
| 
| I'm not sure what's going on here, but it looks funny.

Yup.  Please try the following patch.

Thanks,

jwe


Tue Jan 20 17:02:19 1998  John W. Eaton  <address@hidden>

        * variables.cc (Fexist): If local symbol is undefined, check
        global table.


*** src/variables.cc~   Tue Jan 13 13:03:12 1998
--- src/variables.cc    Tue Jan 20 22:26:58 1998
***************
*** 351,357 ****
      }
  
    symbol_record *sr = curr_sym_tab->lookup (symbol_name, 0, 0);
!   if (! sr)
      sr = global_sym_tab->lookup (symbol_name, 0, 0);
  
    retval = 0.0;
--- 351,357 ----
      }
  
    symbol_record *sr = curr_sym_tab->lookup (symbol_name, 0, 0);
!   if (! (sr && sr->is_defined ()))
      sr = global_sym_tab->lookup (symbol_name, 0, 0);
  
    retval = 0.0;



reply via email to

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