lua-users home
lua-l archive

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


David Kastrup wrote:
>> The same argument can be used for what I am trying to do, only I
>> *have* to use temporary variables.  What I was trying to do is:
>> 
>> function Position()
>> 	return x,y
>> end
>> 
>> function Dimensions()
>> 	return w,h
>> end
>> 
>> function push_clip(x,y,w,h)
>> 	-- Do stuff
>> end
>> 
>> push_clip(Position(), Dimensions())
> 
> See how bad the idea is?  Hide away the definition of Position and
> Dimensions, and you have _no_ clue whatsoever what arguments can be
> affected from "Dimensions".  Worse: a bug in Position will clobber
> the relation between w, h, and Dimensions, leading to symptoms in an
> area completely unrelated to the actual bug.    

The same is true for the last argument of the list. Example:

function logerror(msg, fatal)
  print(msg)
  if fatal then os.exit(fatal)
end

logerror(getlasterror())

local errno
-- And then someone convert getlasterror from:
function getlasterror() return strerror(errno) end
-- into:
function getlasterror() return strerror(errno), errno end
-- and your program starts exiting unexpectedly.

So far the only real argument in favor of truncation on that discussion
is that it's an implementation limitation. All other arguments are
either irrelevant (a matter of personnal preference) or applicable to
the last argument too.

The fact is that the special treatment for the last argument is an
inconsistency. Also, if we had no truncation (that's an interpreter
change, not a syntax change), it would be possible to force truncation
(with extra parentheses), whereas now, with truncation enabled, you
cannot prevent it.

I personnaly prefer the way it works now, but it's neither logical nor
natural, it's clearly a Lua-ism.