[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: new thought experiment: what would you add to Lua ?
- From: Jim <djvaios@...>
- Date: Sat, 15 Sep 2018 18:49:56 +0200
On Fri, Sep 14, 2018 at 10:22 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
> function Oo(x) return tonumber(x, 8) end
> function Ob(x) return tonumber(x, 2) end
yes, i know that tonumber() can be used for this.
i also added a c function to my library that parses a given string arg
(containing an octal integer literal) with sscanf()
(btw: what is more efficient: tonumber or the c function approach ?).
but there should be direct support for those integer literals by
the language itself, as is usual in other languages.
this would also be more efficient as it does not need a string to hold an
integer literal and saves the function call to convert this very string
to an integer which seems highly inefficient to me.
do c or fortran handle that situation the same way ?
given the case that the literal is illegal, direct language support would
detect it at compile time, while the string converting approach would
only detect it at runtime.
omiiting integers (and direct bit operations) and
using floats exclusively was also no good design
decision, especially for cpus that lack a fpu.