Hi,

looking at some new hansl code I'm reminded again that we have a fundamental problem for (mildly) advanced programming, I'm afraid. An example is probably the best way to show what I mean:

<hansl>

function void level2 (string s2)
    eval exists(s) ? s : "nothing"
end function

function void level1 (string s1[null])
    if !exists(s1)
        string s1 = null    # this second null-setting is necessary
    endif
     
    level2(s1)
end function

level1()

</hansl>

What's the problem here: In the level1 function the arg s1 gets a default 'null' value, but this kind of null value cannot be passed on to another function. (Gretl complains if you comment out the if-block.) Note that this is true even though the level2 function properly handles the possibility that its arg s2 might be 'null' (== might not exist) !

Instead a hansl programmer is forced to check for the null value of s1, and then --a little absurdly-- the programmer must set it to 'null' yet again. This feels quite stupid, to be honest. (No offense intended, of course!) And it also wastes lines of code, making everything harder to read.

Wouldn't it be possible that for every function argument --I know, except for the list type with its special role-- that has a null value from the outer scope, this null value is automatically "copied" to the function's inner scope? Basically that gretl automatically executes the equivalent of the if-block above? I think this would make it much easier / more elegant to write  real-world hansl code with nested function calls.

thanks

sven