lua-users home
lua-l archive

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


Hi David,

It seems like you're talking about this feature
(http://msdn.microsoft.com/en-us/library/7932e88z.aspx). While
ZeroBrane Studio doesn't support it directly, any Lua IDE that
supports debugging and remote console will allow you to do what you
want (even though not in the same way VS does it).

For example, in ZeroBrane Studio you can run the following example
under the debugger:

print("Start")
local foo = 0
for i = 1, 3 do
  local function bar(a)
    print("In bar")
  end
  foo = i
  print("Loop")
  bar()
end
print("End")

When you are inside the "for" loop after bar is defined, switch to
"Remote console" tab and update bar value using something like this:

> bar = function(a) print("In (updated) bar") end

Next time bar() is called it will print "In (updated) bar". If you
need the change to apply to other iterations, move "local function
bar()" definition outside of the loop.

Essentially, from the console you can directly manipulate all the
variables and functions of the running process.

In general, you are asking about a particular feature in some IDE (in
this case VisualStudio), which does require some development
environment that supports debugging and some sort of interactive shell
to modify values on the fly. You will be "locked into" using that
development environment as not every one may be providing what you
need. I find "locked into" argument to be a bit misplaced as you are
looking for something that can help you learn the language and this is
exactly what ZeroBrane Studio was designed for.

I have considered extending the scratchpad mode that Kevin referred to
to do something closer to Edit and Continue, but for a pure Lua
solution it requires static analysis of the code to identify the
smallest function that can be updated without changing anything else
and some clever stack manipulation to get that function updated while
the process is being debugged. Based on the quick and dirty testing
I've done it's not impossible, but not at the top of my list at the
moment.

Paul.

On Thu, Jun 21, 2012 at 12: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
>> >
>>