yinung at Gmail schrieb:
Dear all,
I tested the User-defined functions and found some potential errors.
For example, my function is:
<script>
function test (series y, int order[0:2:1], string option[null])
if option="nc"
printf "%s\n","empty"
else
printf "%s\n","no options"
end if
end function
</script>
the argument, string option[null], above should indicate that the
"option" string should be optional.
After normally processing it as a package, I execute this function via
GUI (the same via command line). If I choose the default "null" as
automatically specified by gretl, I got an error:
"The symbol 'otion' is undefined... error evaluating 'if' "
Maybe 'undefined' is a little misleading, but otherwise I think this
part of gretl's behavior is ok, at least from what I'm used to in other
languages: 'null' is not a string type and what the result of the
comparison of 'null' and the string "nc" should be is not obvious IMHO.
I think there is a isstring() function in gretl that could be used here.
If I type any other strings, it works as normal.
If I give no string at all in the text box, gretl tells me:
"Argument 3 (option) is missing"
I agree this looks like a bug.
-sven