repl

Last updated:

0 purchases

repl Image
repl Images
Add to Cart

Description:

repl

A REPL for Dart. #
This package is no longer being maintained. Please see https://pub.dev/packages/interactive for a more full featured and ready to use REPL for Dart. #
Prior art #
Based on early version of a proof of concept REPL environment for Dart from a pair of articles by Andreas Kirsch and an example in the Dart SDK tests
and the recharge package
Features #

✅ MVP with expression evaluation
✅ Use code from BlackHC's work to parse input for statements vs expressions
✅ Use cli_repl for better repl ergonomics
✅ Use standard pub activate for package to run its binary instead of shell script
✅ Improve usage documentation
✅ Use hotreload with a scratchpad file
❌ ?? Support built in package imports
❌ ?? Support arbitrary package imports
❌ ?? Use scratchpad with dedicated Isolate

?? - not clear if this is a workable approach
Usage #
To install the repl use:
dart pub global activate repl
copied to clipboard
Then as long as the pub system cache is on your path you can run it using: drepl
Supported features #
You can currently use expressions and statements as well as a few built-in's are supported (see below), its already possible to do a few useful things with the REPL.
For instance you can do JS style IIFE's:
> (){final data = ['this', 'is', 'a', 'test']; for(int i = 0; i < data.length; i++) print(data[i]); }()
copied to clipboard
But of course that is a bit contrived an example as you could also do:
> ['this', 'is', 'a', 'test'].forEach((x) => print(x))
copied to clipboard
Some statements are also possible, eg.
> int sqr(int a) => a*a;

> sqr(5)
> 25
copied to clipboard
Built-in's
print() - print to output
reload() - trigger a hot-reload (doesn't work well at the moment)
Editing, History, Shortcuts
see the cli_repl package documentation for supported short-cut keys.
Development #
Clone this repo, then from the top level of this repo and then run using:
dart bin/main.dart
copied to clipboard
Future plans #
A more powerful though much more involved implmentation route would be to use the Dart embedding API, perhaps via FFI to avoid needing to deal with too much c/c++ dev, assuming its possible for DartVM to call into itself via FFI using the embedding api?
Contributing #
All contributions: PRs, bug reports, feature requests, documentation are most welcome.
Contribution guidelines: TODO.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.