lua-users home
lua-l archive

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


Following this concept, in the code below:

function f(x,y)
end
function g()
	return '1','2'
end
f(g(), nil)

'f' only receive one parameter, right?
but shouldn?t this statement also work like the one before?

	tonumber(g(), nil)

in which only one parameter should be received by the tonumber function?

but it actually produces an error message:

error: bad argument #2 to `tonumber' (number expected, got nil)
stack traceback:
  function `tonumber' [C]
  main of string "tonumber(gsub('ab', 'a', ''), nil)"

thank you
Luiz
-----Original Message-----
From: lua-l@tecgraf.puc-rio.br [mailto:lua-l@tecgraf.puc-rio.br]On
Behalf Of Roberto Ierusalimschy
Sent: Friday, April 07, 2000 3:37 PM
To: Multiple recipients of list
Subject: about the new version


...

- in a call like f(g(x)), all results from `g' are passed to `f', when `f' 
is the last/only argument. (This may result in incompatibilities; for 
instance, "write(gsub(...))" will write an extra number, which is the 
second result from gsub. You may correct this case with
  "write(gsub(...), '')", or "local g=gsub(...); write(g)".) 

...

- the nil in next/nextvar is optional ;-) 


-- Roberto