lua-users home
lua-l archive

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

Nick Gammon wrote:
> Thanks to this tip, you can coerce strings into numbers right now,
> rather clumsily:
> arg = "5"
> print (- -arg) --> 5

I may be missing something intrinsic, but:

arg = "5"
print (arg+0)

Likewise, some compiler sugar to convert to treat '+a' as '0+a' would be
easy, not involve any additional opcodes, and would optimise away to
nothing in most cases.

David Given