[Gretl-devel] Default value specification for scalar and integer arguments

Sven Schreiber svetosch at gmx.net
Sat Jul 4 02:31:11 EDT 2015


Am 04.07.2015 um 02:45 schrieb Allin Cottrell:
> On Fri, 3 Jul 2015, Allin Cottrell wrote:
> 
>> On Fri, 3 Jul 2015, Sven Schreiber wrote:
>>

>>
>> But in fact "int foo[0]" seems to be taken as specifying a default of
>> 0. Presumably this should be fixed; unless perhaps there are lots of
>> scripts out there that rely on the undocumented and formally wrong
>> behaviour.

Well I stumbled over this in one of Jack's functions in SVAR...

> 
> * For "int" parameters to user-defined functions, only arguments very
> close to integers are accepted (as with built-in functions).

Yes I think having a common treatment is good.

> 
> * The min and max fields in scalar parameter definitions are now
> respected, which I'm afraid has not been the case to date.

Meaning the bounds weren't checked?

> 
> /* we take a single value with no colon as indicating a default */
> 
> This does seem to be implicitly at variance with the documentation. We
> have to adjust either the parser or the documentation, but which way
> should we jump?
> 
> Is it more common to want to specify a default value, regardless of min
> and max, or to specify a minimum regardless of max and default?
> I guess the former would have to be a lot more common than the latter to
> justify our current practice.

I actually do think (without proof) that specifying a default is more
common, such that the parameter also becomes optional.

Although of course it is also conceivable that somebody writing [0]
intends to enforce a non-negative value, this would not actually have
been possible with gretl's current behavior. So keeping the behavior and
updating the documentation seems the best way to me.

cheers,
sven



More information about the Gretl-devel mailing list