lua-users home
lua-l archive

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


Well, depends on how much control you want - if you simply want to
reload a module, you can create a function to do that for you:

function reload(mod)
  package.loaded[mod] = nil
  require mod
end

It won't give you "hot swapping" so to speak, but it will reset the
function to what you want (in your original example).  See here for
more information:

http://lua-users.org/wiki/ModulesTutorial

Hope that helps!
---------------------
Kevin T. Ryan
(215) 764-6915


On Thu, Jun 21, 2012 at 3:41 PM, yoyomeltz yoyomeltz
<yoyomeltz@hotmail.com> wrote:
> kevin, thanks you much. it does seem to offer what i wanted but the problem
> is i would be locked into an ide that does not seem to offer much else.
>
> there has to be a simple way to dynamically reload code as needed via a
> console/command.line or other simple solution.
> if visual basic from microsoft can do it and python can do it, then why
> should i be an issue for Lua.
> even visual basic 6.0 from 10 years ago can do that.
>
> it seems to me this such a feature is a pre-requisite for learning any
> language, espcially a lightweight scripting language.
> so does anybody have any other suggestions?
> thanks in advance
>
>> Date: Thu, 21 Jun 2012 12:03:35 -0400
>> From: kevin.t.ryan@gmail.com
>> To: lua-l@lists.lua.org
>> Subject: Re: newbie: how to modify lua code while the program is running
>> like visual basic
>
>>
>> You may want to try ZeroBrane Studio:
>>
>>
>> http://notebook.kulchenko.com/zerobrane/live-coding-in-lua-bret-victor-style
>>
>> I haven't tried it (Vim user :)), but the video looks impressive and
>> sounds like it might be what you want.
>> ---------------------
>> Kevin T. Ryan
>> (215) 764-6915
>>
>>
>> On Thu, Jun 21, 2012 at 11:36 AM, yoyomeltz yoyomeltz
>> <yoyomeltz@hotmail.com> wrote:
>> > hi, my name is david and this is my first post, so i do aplogize if i am
>> > doing something lame....
>> > and yeah, i know to use 'Lua' and not 'lua' and not 'LUA', lol i already
>> > made that mistake
>> >
>> >
>> >
>> > there is a feature called Edit and Continue.
>> > if i am running a program in the debugger, i am able to modify the code
>> > of a
>> > function while in the debugger.
>> > both Visual Basic for Visual Studio and Visual Basic for Applications
>> > can do
>> > that. in fact, VBA can modify a function while the debugger is debugging
>> > that specific function.
>> >
>> > as you can imagine this approach enables me to build program
>> > 'on-the'fly', i
>> > can learn iup without having to stop the program, change the code,
>> > debug,
>> > fix the issue, run the program again, debug it again, and over and over.
>> >
>> > so with Lua, i need that same functionality.
>> > i am trying to learn Lua and IUP.
>> > for example, lets say i have used the following code:
>> > ------------------------------------------
>> > require("iuplua")
>> >
>> > ml = iup.multiline{expand="YES", value="I ignore the 'g' key!",
>> > border="YES"}
>> >
>> > ml.action = function(self, c, after)
>> >    if c == iup.K_g then
>> >      return iup.IGNORE
>> >   else
>> >     return iup.DEFAULT;
>> >   end
>> > end
>> >
>> > dlg = iup.dialog{ml; title="IupMultiline", size="QUARTERxQUARTER"}
>> > dlg:show()
>> >
>> > if (iup.MainLoopLevel()==0) then
>> >   iup.MainLoop()
>> > end
>> > ------------------------------------
>> >
>> > i would like to be able to change that ml.action while the program is
>> > being
>> > debugged.
>> > i was not able to get that to work.
>> > so i tried to place that ml.action in another lua file name second.lua.
>> > to the main program i added a require('second') to that other .lua file.
>> > if i change the code in the code in second.lua, while the debugger is
>> > active, i have the same problem.
>> >
>> > i would like to switch from VB to Lua, i am loving Lua!
>> > this is the only real issue i need to resolve.
>> > thanks in advance,
>> > david
>> >
>>