lua-users home
lua-l archive

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


	Hi Roberto

	Would you provide a "smart" (not a good name, but you know
what I mean :-) format to read a number in whatever format (as "*n")
but return an integer (as "*i") if appropriate?
	In fact I don't use anything like that, just a thought :-)
Suppose the file will provide table keys; there would be two conversions:
from file (integer) to number (fp), then from number to key (integer).
Unless I know all numbers are integers and use "*i".

I guess that, if you do not know what you are reading, the values could
also be strings, or booleans, or whatever, not only numbers. A "smart"
read should be able to read any basic Lua value, not only numbers.
	I meant a file produced with a previous Lua version, where
tostring() should have been used to produce the numbers.
	Anyway, since tostring() in Lua 5.3 will produce different
string representations for integer and floating-point numbers (can I
assume that?) it won't be more useful to have "*i" format to read "1.0"
and convert it to the integer 1 ?

	Regards,
		Tomás