The last time Hackerfall tried to access this page, it returned a not found error. A cached version of the page is below, or clickhereto continue anyway

l2l/samples/sample09 at master meric/l2l GitHub

Sample09

This is a prototype of a time travelling debugger for Lua, inspired by Elm's.

Quickstart.

Download Love2d from http://love2d.org. Version 0.9.x. Run with path_to_love2d/love .

Contents

How it looks

  1. Move with Left, Right, jump with Up.
  2. Press "P" to toggle Pause and Resume.
  3. Once paused, press the slider to move the program backwards and forwards.

Pitfalls

About

Saw it from http://debug.elm-lang.org/edit/Mario.elm

Elm's functional programming and pure functions are tools to assist building a time travelling debugger.

Lua's functions, on surface, are mutable and can have side effects, and would greatly impede the implementation of a time travelling debugger like Elm's.

However, if we switch our perspective, really, every Lua functions are pure functions. A Lua function takes the global state, the upvalues state, the input parameters, and returns some values, as well as a set of modifications to the global state, and the upvalues state. As long as we use the same global table, the same set of upvalues, and the same arguments, a Lua function will almost always return the same values, and do exactly the same thing. This prototype is implemented based on this fact.

There are functions that use information or perform actions that affect the world outside of the global state or upvalues, for example, io.read and io.write. All we have to do is tell the debugger that these are impure functions whose returns must be recorded, so they can be played back without being run, while the debugger is performing the "time-travel". This is done through the record function.

love.keyboard.isDown = record(love.keyboard.isDown)

See usage in main.lua.

Other Programs

This debugger can work with any Lua program, not just with Love2d.

Continue reading on github.com