lua-users home
lua-l archive

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


On Wed, Nov 14, 2012 at 12:14 AM, Xavier Wang <weasley.wx@gmail.com> wrote:
> Very good idea, but, shouldn't this can be a sub type just like short
> string and long string?
>
> the only new feature is '//'(?) for integer division, I love it, I
> just dream it for a long time when I write Lua.

Indeed, just having the integer operations would be great, regardless
of whether we have types.

In terms of having types, not quite sure I see how they could be
declared in a simple way as 1 vs 1.0 is very confusing and not
backward compatible. Statically typed languages have this much easier.

Luajit on ARM has an automatic mode where it uses integers where
possible but will coerce to floats when needed. This makes it
transparent rather than explicit which is another option to consider
(although it has some edge cases that must be carefully considered).

On the other hand, the advantage of having subtypes is that they give
the option of extending them in future. I love languages that have
unbounded precision integers (eg Haskell, that has a great set of
numeric types). Of course you can just implement these as a library,
but if there was a mechanism to declare different number types perhaps
it could be made extensible to user types so these additions could be
less verbose.

Justin