|
From: Ethan A M. <merritt@u.washington.edu> - 2006-08-14 05:49:10
|
On Sunday 13 August 2006 10:21 pm, you wrote:
> >> This is the correct patch! With this patch, the exists(...) works as
> >> expected.
> >
> > I disagree.
> >
> > Before
> > -------
> > gnuplot> foo = 8
> > gnuplot> if (!exists(foo)) print "Hi"
>
> This is wrong! You must write exists("foo"). The argument of exists() must
> always be a string:
You are missing my point.
foo is a variable. It may hold a string ("xxx") or it may hold an integer (9).
It is legal to call
if (exists(foo))
in the first case, and the return code is 1, which tells you that foo contains
the name of a defined variable.
As I see it, if foo = 9 then exists(foo) should return 0, which tells you that
foo does _not_ contain the name of a defined variable. That is what it does
now, and I think it is correct. Daniel's patch would have it error out rather
than returning.
> gnuplot> help exists
> `exists("X")` returns 1 if a variable named X has been defined,
> otherwise it returns 0.
^^^^^^^^^^^^^^^^^^^^^^^
That is exactly what I am saying. If the argument to exists() is not a
defined variable name (i.e. a string), then exists() should return 0.
Not error out; return 0.
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742
|