forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

dofile vs. require

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
Sprak



Joined: 27 Sep 2005
Posts: 7
Location: Stockholm, Sweden

PostPosted: Mon Oct 03, 2005 5:57 am    Post subject: dofile vs. require Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Durante



Joined: 02 Oct 2005
Posts: 65
Location: Austria

PostPosted: Tue Oct 04, 2005 11:27 pm    Post subject: Reply with quote

That's because "require" is intended for libraries and should therefore only load each required file one time. More about dofile vs. require is in one of the early chapters of the book.
Back to top
View user's profile Send private message
Sprak



Joined: 27 Sep 2005
Posts: 7
Location: Stockholm, Sweden

PostPosted: Thu Oct 06, 2005 5:13 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group