dyon icon indicating copy to clipboard operation
dyon copied to clipboard

Develop REPL-specific designed runtime for Dyon

Open bvssvni opened this issue 7 years ago • 6 comments

One potential use case for Dyon is as an on-screen shell programming language for game engines. Since the current runtime does not support start/stop, it might be necessary to develop a REPL-specific designed runtime. This could be a subset of Dyon.

To make REPL behavior consistent across projects, one could build in the shell logic into the runtime.

  • Execute a single line of code at a time
  • A history of previously executed commands
  • Not allowed to declare new functions (use closures instead)
  • Declare variables and refer to them later
  • Loops are supported for repeating commands
  • Expression dependency graph for mutation and injection (experimental idea)

Expected REPL behavior

  • If syntax check fails, then hitting Return gives a new line instead of executing (makes it easy to write multi-line commands)
  • Select referenced variable with mouse cursor (used by pop-up editors for easy mutation)
  • Dependency graph mutation with $ prefix (reruns command when variables it uses are mutated)
  • Dependency graph injection with # prefix (checks result and compares for equality)

Example of dependency graph mutation:

x := 2
$println(x)

If x is mutated e.g. by a pop-up editor, then println(x) is executed each time the variable changes.

Example of dependency graph injection:

$println(#selected_cube())

When selected_cube() changes as a result from in-game editing, the new value is printed out. This makes it possible for the shell to react to changes.

Variables that are referenced in an expression can be selected and mutated without any # prefix. This can be used by pop-up editors to make instant changes to a variable.

REPL specific commands

REPL specific commands are prefixed with :, e.g. :clear(). These commands are not part of the history.

  • :clear() for clearing history
  • :load(<src>) for loading a module into context (all previous loaded modules are used as imports)
  • :help() for viewing all REPL specific commands
  • :functions() for listing all available functions
  • :doc(<name>) show docs for a function

bvssvni avatar Aug 28 '17 00:08 bvssvni

Did you already find a resolution regarding the basis for the dyon REPL? I'd like to help out if you're short on manpower but for that some of the open questions regarding the repl need to be resolved first.

Eastwooder avatar Mar 15 '18 20:03 Eastwooder

Perhaps it would be easier if we had an executable bytecode representation?

bvssvni avatar Mar 16 '18 22:03 bvssvni

It might be possible to do this without much redesign. For example, add a custom method to Runtime which doesn't roll back the whole stack.

bvssvni avatar Jun 17 '18 22:06 bvssvni

Any updates?

korczis avatar Sep 03 '21 13:09 korczis

@korczis I'm not sure yet how to make it repl compatible.

bvssvni avatar Sep 04 '21 20:09 bvssvni

@korczis btw, you can join the Discord server to discuss this: https://discord.gg/TkDnS9x

bvssvni avatar Sep 04 '21 20:09 bvssvni

Replaced by https://github.com/PistonDevelopers/dyon/issues/735

bvssvni avatar Sep 10 '23 13:09 bvssvni