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

Sven Schreiber svetosch at gmx.net
Fri Jul 3 15:39:47 EDT 2015


I want to ask whether the following (which is working!) is actually 
according to the hansl spec. Consider the session at the end of the message.

Hansl allows to specify the default value [0] both for 'scalar' and 
'int', without requiring minimum or maximum values. But the way I read 
the paragraph "Function parameters: optional refinements" in the user 
guide, this would seem to be actually a syntax error. Instead for 
non-bool types it should be [::0].
Or if gretl is actually treating this as an implicit bool, what are the 
consequences of that? None, i.e. can the function body still do 
arbitrary calculations with the passed scalar value?

Also (and I feel like having deja-vus again) notice that in the check2() 
function an integer parameter is specified, but if the caller passes 
0.5, there is no type error, instead the argument is converted to its 
integer component. I do not think this is obvious, is this documented 


? function void check1 (scalar in[0])
 > print in
 > end function
? function void check2 (int in[0])
 > print in
 > end function
? check1()

              in =  0.00000000
? check1(3)

              in =  3.0000000
? check1(1)

              in =  1.0000000
? check1(0.5)

              in =  0.50000000
? check2()

              in =  0.00000000
? check2(3)

              in =  3.0000000
? check2(1)

              in =  1.0000000
? check2(1.6)

              in =  1.00000000

More information about the Gretl-devel mailing list