lua-users home
lua-l archive

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


2015-05-08 14:02 GMT+02:00 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
>> alias lua='lua -l mathx -e "math=mathx" -i'
>
> I'm sure you know what you're doing but, for the record, doing "math=mathx"
> kills these functions because mathx deals exclusively with floats:
>
>  maxinteger      mininteger      random          randomseed      tointeger
>  type            ult              max            min
>
> Anyway, instead of an alias you can set LUA_INIT or LUA_INIT_5_3 to
>         math=require"mathx"

My solution is bad because of two reasons: "-i" means one can't just
run Lua scripts.

Your solution is bad because those nine functions are only accessible
via package.loaded.math. (My solution is bad because of that too.)

My current solution still uses an alias, and my be bad because of
other reasons, but at least it solves those.

alias lua='LUA_INIT="setmetatable(math,{__index=require[[mathx]]})"
/usr/local/bin/lua'