lua-users home
lua-l archive

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


2018-07-28 10:21 GMT+02:00 Gavin Wraith <gavin@wra1th.plus.com>:

> 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.

If you only intend to use those builds for programs you wrote
completely by yourself, it may well be a good thing. If you need any
module whatsoever from a repository like LuaRocks, YMMV.

> 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

This is easy to do yourself by monkey-patching 'type'.

> and all arithmetic binary operations restrictable
> to when the two arguments have the same type.

No more 2*math.pi, it's got to be 2.0*math.pi.  Not even C demands that.
Hello, FORTRAN II, never expected to see you again after all these years.

> By forcing the user

Big Brother is watching you.

> I understand the reasons given for conflating integers with
> numbers in the early days of Lua,

They are still valid. Lua is a language used by 10-year old kids who
play World of Warcraft.

> but I think they have the flavour of an expensive deception -- which is in fact
> unnecessary.

The phrase "expensive deception" has the flavour of political posturing.

The Lua 5.3 idea is: if you wish to exploit the special properties of
the hardware representation of integers (such as bit operations) you
can. If you don't, it is not necessary that you even know about
integers.