lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

  Show(nil)   --> Show(true)  -- use default
  Show(true)  --> Show(true)  -- arg not nil, use arg
  Show(false) --> Show(false) -- arg not nil, use arg

Seconded.  It seems like the right semantic in this case is:

function f(x,y=0) --> function f(x,y)  y= y==nil and 0 or y;

That's still fairly easy to patch, but, has a behavior that's closer to what a C++ programmer might expect.

Are you planning to allow things other than constants to be used as defaults?

If so, watch out for the potential trouble that can happen near self-referential expressions.  

local y={1,2,3}
function f(x=f, y=y[2]) --> naive implementations may segfault here

Peter's old table unpack patch still has a bug in the 'local a in a' case.  Which reminds me, I should really get around to posting a fix for that on the wiki...