|
From: Daniel J S. <dan...@ie...> - 2006-05-30 00:44:54
|
Ethan A Merritt wrote:
> On Monday 29 May 2006 03:28 pm, Daniel J Sebald wrote:
>
>>This seems like a bug, even though the syntax is incorrect... but a user might think the syntax is correct if gnuplot doesn't complain but rather returns a non-zero value that will always test positive.
>>
>>gnuplot> print defined("foo")
>>141158968
>
>
> We don't have a user-visible TBOOLEAN type,
> so any non-zero value represents "TRUE"
Right. The point is that the test and the result are meaningless. foo was never defined, so if anything the result should be zero. But this is not proper syntax. Proper syntax is
`defined(X)` returns 1 if a variable named X has been defined, otherwise
it returns 0.
so,
gnuplot> print defined(foo)
0
which is correct. However, the user could unknowingly be typing
defined("foo")
oblivious to the fact that it is meaningless.
>>Also, would it be useful to extend defined() from just variables to functions as well?
>>Say, return 1 if user defined variable, 2 if internal variable, 3 if user defined function,
>>4 if internal function.
>
>
> What would you do with this information?
Pretty much any kind of test one would do similar to checking for variables, I would guess.
> That comment is confusing to me already. My reading of the
> code leads me to believe that gnuplot will always provide a
> lgamma() function. Again there is a question of whether this
> came from a system library or not. But either way you can
> use the function.
Yes, I kind of concluded that too. Just toss the comments and make life easy. Even still, defined() on functions might have a purpose.
Dan
|