On Thu, 2 May 2019, Allin Cottrell wrote: > On Thu, 2 May 2019, Allin Cottrell wrote: > >> On Thu, 2 May 2019, Sven Schreiber wrote: >> >>> not sure why the following fails, given the documentation of 'argname': >>> >>> <hansl> >>> function void ch(matrix m[null], string s[null]) >>> if exists(m) >>> eval argname(m) >>> elif exists(s) >>> eval argname(s) >>> endif >>> end function >>> >>> string s_in = "hey" >>> ch(, s_in) # error, expect "s_in" >> >> This is due to an ambivalence specific to string variables. > > Well, I now think this (mis)behavior is new, fallout from my recent addition > of an optional second argument to argname(). I'll work on a fix.
Now fixed in git and snapshots. Here's the test script that I'm adding to my test set so this won't go wrong again unnoticed. <hansl> function void strcheck (string s[null]) if exists(s) eval argname(s, "defaultname") else print "no arg, OK" endif end function function void matcheck (matrix m[null]) if exists(m) eval argname(m, "defaultname") else print "no arg, OK" endif end function string main_s = "hey" strcheck(main_s) strcheck("lucky") strcheck() matrix main_m = I(3) matcheck(main_m) matcheck(I(2)) matcheck() </hansl> Allin