[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: The border crossing - integers in a ghetto
- From: Gavin Wraith <gavin@...>
- Date: Sat, 28 Jul 2018 09:21:28 +0100
I have only just woken up to the possibility of
compiling recent versions of Lua using the flags
LUA_NOCVTN2S and LUA_NOCVTS2N to suppress
automatic conversion between numbers and strings.
This seems to me a good thing, because it means
that such conversions have to be made explicit
by use of 'tonumber' and 'tostring'; the programmer
is given more control over them.
But I would like to see this extended to numerical
conversions as well. I apologize if I am raking up
a topic that must have appeared frequently. In
fact I would like to see the type 'number' split
into 'integer' and 'number':
print (type (1)) --> integer
print (type (1.0)) --> number
and all arithmetic binary operations restrictable
to when the two arguments have the same type.
By forcing the user to use explicit 'tointeger'
and 'tonumber' conversions, the border-crossing
[ excuse my bad taste in using such a sensitive simile
in these vile times ] between the enclave of whole
numbers within the larger kingdom of more general
numbers becomes more controllable.
How about it for version 5.4.1 ? I am not asking for
Haskell-like strong typing, but would not this make
the compiled code somewhat simpler? The separation
of integers from numbers exists internally, but
it is not brought out fully to the user. I understand
the reasons given for conflating integers with numbers
in the early days of Lua, but I think they have the
flavour of an expensive deception -- which is in fact
Thanks for your patience.
Gavin Wraith (email@example.com)
Home page: http://www.wra1th.plus.com/