lua-users home
lua-l archive

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





On Thu, Jun 26, 2014 at 7:36 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> > The other place where truncation (already) occurs is "outside" Lua,
> > in the API, when the C code uses things like lua_checkinteger. This
> > is the only place where the change would affect compatibility:
> > string.sub("abc", 2.3) currently behaves in a non-specified way
> > (although most certainly it is equivalent to string.sub("abc", 2)
> > and we are afraid some programmers assume this behavior); current
> > 5.3w specifies that 2.3 should be truncated to 2, while with this new
> > proposal Lua would raise an error.
> >
>
> Are you saying that a float value would return an error, or a non-integral
> value would return an error?

A non-integral value would raise an error, as an out-of-bound float
already raises an error in work3. Something like 10.0 still behaves
like 10 in most situations.

-- Roberto



Thank you for clarifying. I have no opinion, except that I'd slightly prefer "defined" behavior.

Like other places in Lua, this one seems like something someone could wrap, if they needed it to work a certain way.

-Andrew