808 posts
Posted 05 June 2013 - 12:52 AM
I can probably program my own implementation of it by changing loadfile but I'm curious why it's not in the lua vm. Can it be added?
EDIT: After tinkering and playing with the idea, it turns out to be rather difficult to do with pure lua because of how function environments are changed.
8543 posts
Posted 05 June 2013 - 01:09 AM
I'm not sure I can speak as to why it doesn't use that model, but the API loading/unloading that it does use works well. What can you do with require that you cannot with the API loading?
1688 posts
Location
'MURICA
Posted 05 June 2013 - 01:38 AM
Correct me if I'm wrong, but dofile() is pretty much require() but with a different path naming system, e.g. dofile('folder/script.lua') would be require('folder.script'), so require isn't really needed. The API loading and unloading system is pretty much a remake of the module system too.
2447 posts
Posted 05 June 2013 - 07:46 AM
Basically, it would have broken out of the sandbox in a big way. That is why it isn't enabled. require was really dangerous - it even allowed you to reload the LuaJ IO library. Full access to whatever Java can access on your system, anyone? ;)/>
7508 posts
Location
Australia
Posted 05 June 2013 - 07:49 AM
Basically, it would have broken out of the sandbox in a big way. That is why it isn't enabled. require was really dangerous - it even allowed you to reload the LuaJ IO library.
In no way saying you should add it, but could you not have just overrode it with a `safe` version like you did with other functions?
Full access to whatever Java can access on your system, anyone? ;)/>
/sarcasm Yes please :P/>
808 posts
Posted 05 June 2013 - 04:56 PM
I'm not sure I can speak as to why it doesn't use that model, but the API loading/unloading that it does use works well. What can you do with require that you cannot with the API loading?
Well a lot of lua libraries use the module paradigm so it would allow us to use lots more projects outside CC.
Basically, it would have broken out of the sandbox in a big way. That is why it isn't enabled. require was really dangerous - it even allowed you to reload the LuaJ IO library. Full access to whatever Java can access on your system, anyone? ;)/>/>
That makes sense. Good reason!