lua-users home
lua-l archive

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


On Mon, Nov 26, 2012 at 12:00:14PM -0800, Sven Olsen wrote:
> > I'm growing more convinced that "wants precision in computation" is a
> > property of code, not of dynamically typed values. I know I may be a victim
> > of confirmation bias.
> >
> 
> My own gut feeling is the same. But I'm unsure how one might implement such
> a code property in a high level language like Lua.
> 
> Perhaps we could follow the _ENV model?  Have an upvalue _PRECISION that's
> implicitly set to "float64" any time a new chunk in loaded.  Meaning that
> inside that scope, numeric operations should overflow as 64-bit floats.

If we exclude the ability for an implicit declaration at load time, then
type coercion could happen at compilation time by selecting the appropriate
ops. Then there wouldn't be any run time cost to the expanded typing.