On Thu, 8 Jan 2015, Sven Schreiber wrote:
Am 07.01.2015 um 21:33 schrieb Riccardo (Jack) Lucchetti:
> On Wed, 7 Jan 2015, Sven Schreiber wrote:
>
>>
>> Now I have the following debug code inside this function, and I report
>> the output as comments:
>>
>> # should give 0, since 'thresh' exists in the function's scope:
>> check = isnull(thresh)
>> # but actually gives 1:
>> print check
>> # but in this very next line, 'thresh' is accepted (no error):
>> string mys = argname(thresh)
>> # and gives the correct passed argument's name "ave_inc_gr":
>> print mys
>>
>> This feels very weird, or am I blind and missing something obvious?
>
> Careful: isnull() doesn't mean "isn't there": it means
"it's there, and
> takes the value 'null'".
>
Suppose you're right and 'thresh' has the value 'null', then why
does
argname(thresh) return (correctly) "ave_inc_gr"? And in reality I was
trying to do something useful (of course!) with the series ave_inc_gr
inside the function, and got the error "no such symbol" or "doesn't
exist" or something like that. The isnull() thingy is just another test
I did to pinpoint the problem.
BTW, the doc about isnull() says the question is whether the arg "is the
identifier for a currently defined object". This is not quite the
definition that you gave.
I agree. In the context you're talking about, the only case in which
isnull() should return 1 when applied, inside a function, to an
argument of that function, is when the parameter in question has a
"null" default and the caller has left the argument slot empty.
Finally, I had used the function before, and it had worked ok. Of
course
I can never rule out 100% that something else hasn't changed, but I
think there is a chance that this is new gretl behavior for some reason.
It sounds as if there must be a bug in this area, but I can't
reproduce it in a simple case. For example the following works as
expected:
<hansl>
function void test_isnull (series thresh)
eval isnull(thresh)
string mys = argname(thresh)
print mys
end function
nulldata 10
series ave_inc_gr
test_isnull(ave_inc_gr)
</hansl>
If you could send a test case off-list I'll be glad to take a look.
Allin