|
From: Daniel J S. <dan...@ie...> - 2006-08-14 05:28:59
|
Ethan A Merritt wrote:
> On Sunday 13 August 2006 09:37 pm, you wrote:
>
>>>>>Shouldn't we expect the same error message?
>>>>>(and "internal error: ...", not "... error : ...")
>>>
>>>Is this 4.2 critical?
>>
>>Yes; you've shown that exists() doesn't work properly.
>>
>>
>>>The important thing is the return value, not the error message.
>>
>>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"
> Hi
>
> After
> -----
> gnuplot> foo = "baz"
> gnuplot> if (!exists(foo)) print "Hi"
> Hi
> gnuplot> foo = 8
> gnuplot> if (!exists(foo)) print "Hi"
> internal error : non-string argument
>
>
> Are you arguing that the old behaviour was wrong, and the
> new behaviour is correct?
>
> I think the original behaviour was correct:
> if foo does not point to the name of a variable, exists(foo)
> returns 0. After Daniel's patch it doesn't return at all;
> it errors out. That means you cannot use exists(foo) to
> test whether it contains the name of a variable.
Again, I see what you are saying. However, before the patch, let's say that foo is not defined. Then this:
gnuplot> print exists(foo)
undefined variable: foo
should also return a 0 by the same logic that
gnuplot> foo = 8
gnuplot> print exists(foo)
0
returns a zero. That is, foo doesn't contain the name of a variable; it doesn't contain anything because it doesn't exist. I ask if, in fact, "exists" does intend to answer that question, i.e., Contains a variable? Perhaps there should be another function for that, isint(), isvar(). ??
Also in the old behavior, how is one to interpret the following?
gnuplot> print exists(23)
0
That 23 doesn't contain a variable? In one sense, 23 does exist. It's an integer value, e.g., one types "plot 23" and gets a valid plot.
So, I'm on the fence on this one. I don't see a convincing argument for one way over the other just yet.
Dan
|