AssemblyScript / assemblyscript

A TypeScript-like language for WebAssembly.
https://www.assemblyscript.org
Apache License 2.0
16.79k stars 655 forks source link

[Feature request] Add REPL #699

Closed MaxGraey closed 5 years ago

MaxGraey commented 5 years ago

It will be nice to have REPL with history and minimal environment. I guess we could reuse some urils from node.js like "repl" module:

const Repl  = require('repl');

const repl = Repl.start({
  prompt: 'assemblyscript> ',
  useColors: true,
  ignoreUndefined: true
});

repl.on('line', line => {
   line = line.trim();
   // try compile assemblyscript for this line here
});
dcodeIO commented 5 years ago

Since we are talking about a static compiler here that cannot evaluate an additional line ad-hoc, it looks like the only way this can be done is to keep a complete history of the input (discarding invalid input) and recompile everything with a new line added, including any variable assignments, function calls etc. This might work somehow, but I wonder if it's a good match due to compile time delay.

MaxGraey commented 5 years ago

I guess it possible. For example Rust has some unofficial crates for this. Like evcxr_repl and runner. Also see RFC proposal.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.