lua-users home
lua-l archive

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

It was thus said that the Great Roberto Ierusalimschy once stated:
> > The workaround has already been explicitly shot down in this thread:
> > it's a runtime transformation which means you take a performance hit
> > every time you use one. It HAS to be done at the lexer level to be
> > practical for anything that needs to worry about scalability. This
> > plus binary literals are things that have been in demand for quite a
> > while and they're things I think are worth doing -- though they're
> > things that can be done with token filters, too.
> Up to a point. In Java, the "thousand separator" can only be used in
> source code; methods to convert strings to numbers do not accept them.
> I am not sure this would be a good design for a scripting language like
> Lua. On the other hand, to accept thousand separators in floating
> strings like 'tostring("123_527.24")' is not as easy as to simply
> ignore the separators in the lexer.

  I was curious about this, and yes, I can see why---you call one of the
Standard C functions (strtof(), strtod(), strtold()) to do the actual
conversion.  To support grouping separators [1], the code would have to
first walk through the entire number, stripping out the grouping separators,
then call the Standard C function.

  -spc (Or you could convince the C Standards body to support this ... )

[1]	To avoid mixing this concept up with the decimal separator.