Jump to content




Why doesn't CC have the require function and the lua package system?


  • You cannot reply to this topic
5 replies to this topic

#1 ElvishJerricco

  • Members
  • 803 posts

Posted 04 June 2013 - 11:52 PM

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.

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 05 June 2013 - 12: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?

#3 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 05 June 2013 - 12: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.

#4 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 05 June 2013 - 06: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? ;)

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 05 June 2013 - 06:49 AM

View PostCloudy, on 05 June 2013 - 06:46 AM, said:

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?

View PostCloudy, on 05 June 2013 - 06:46 AM, said:

Full access to whatever Java can access on your system, anyone? ;)
/sarcasm Yes please :P

#6 ElvishJerricco

  • Members
  • 803 posts

Posted 05 June 2013 - 03:56 PM

View PostLyqyd, on 05 June 2013 - 12:09 AM, said:

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.

View PostCloudy, on 05 June 2013 - 06:46 AM, said:

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!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users