dofile vs. require
Moderators: Shine, Insert_witty_name
dofile vs. require
A small thing I noticed when using require (for example: require "monkey"; to include monkey.lua into the script). Luaplayer loads the file 'required' and then probably caches it, since any further changes in monkey.lua won't be reflected on subsequent loads of the main lua file (unless you restart luaplayer). However, if you use dofile("monkey.lua") instead, it loads the file anew upon execution.
Yeah, but how does that fit into loading only once even if you restart the application using the library? I totally understand the logic in only loading it once per session, but it feels like more of a cache error than "feature".
Sheesh, that book (Programming in Lua)... With fear of derailing this thread, it's not really written for people not used to Lua, even though that probably was the ambition from the outset. This page however has proven to be my best friend in grasping the intricacies of the whole thing.
Sheesh, that book (Programming in Lua)... With fear of derailing this thread, it's not really written for people not used to Lua, even though that probably was the ambition from the outset. This page however has proven to be my best friend in grasping the intricacies of the whole thing.