Implement q()
#5
Labels
meta-good first issue
Good for newcomers
theme-base
Function implementations
type-enhancement
New feature or request
The current implementation sorely lacks an obvious way to quit. Although you can break out of the repl with
Ctrl+D
, anyone who's booting up a repl for the first time is likely to useq()
.To implement a quit functionality, we need to first implement a new signalling condition to signal a termination. This should be added to the possible R Conditions here:
R/src/lang.rs
Lines 34 to 37 in a902965
Next we need to implement a primitive
q
function. Primitives are callable symbols, and the dispatch to primitive internal calls is handled in this implementation of theCallable
trait:R/src/builtins.rs
Lines 897 to 905 in a902965
Which then calls into the
primitive
function to try to find an appropriate primitive internal call if one exists:R/src/builtins.rs
Lines 771 to 777 in a902965
A new primitive callback for
q()
would need to be added. For now, I wouldn't worry about even handling any arguments. It should just return the new RSignal to terminate the session.And finally, the last step would to respond to this termination signal in the REPL handler:
R/src/r_repl/repl.rs
Lines 54 to 58 in a902965
The text was updated successfully, but these errors were encountered: