[Gretl-devel] scalar function args and NAs

Berend Hasselman bhh at xs4all.nl
Sun Jul 5 13:35:00 EDT 2015


> On 05-07-2015, at 17:08, Allin Cottrell <cottrell at wfu.edu> wrote:
> 
> A question has come up as I've thought about user-function arguments (see also
> http://lists.wfu.edu/pipermail/gretl-devel/2015-July/005850.html )
> 
> Given a scalar parameter, what do we want to do if the caller supplies NA as an argument? What difference, if any, should it make if the parameter is marked as "bool" or "int" rather than plain "scalar"?
> 
> The situation prior to my changes of the last couple of days was that
> NA was always accepted. But along with fixing the bounds checking for scalar arguments, I banned NA for bool and int parameters. I've now had second thoughts (maybe this would break some existing scripts?) and have reverted to the status quo ante.
> 
> But maybe this is something we want to think about. Are there real use-cases where a function writer would want to accept NA for a bool or int argument? Or would it be more convenient for the writer not to have to bother with checking for NAs, in the knowledge that they would be ruled out by gretl?
> 

If using a bool or int with value NA in e.g. a for loop of an if/else gives a gretl error: accept it.

I can envisage a situation where the function is to do something different depending on whether an integer argument is NA, negative or positive.

If a function accepts an NA, then the function should test and check and do whatever it feels is appropriate.
Then if the function does not check then gretl can always issue an error in cases where the use of NA is illegal.

Berend


> Allin
> _______________________________________________
> Gretl-devel mailing list
> Gretl-devel at lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-devel




More information about the Gretl-devel mailing list