From 52e2801fd2709e03077acc1528121ad020d30638 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Sun, 26 Jan 2020 11:36:38 +0000 Subject: [PATCH] nRepl functionality has been added --- README.md | 11 +++++++++++ src/main/java/serene/simple/Main.java | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 08191f3..d0be392 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,14 @@ my [blog](https://lxsameer.com/). ## Repl in order to run the REPL, run `make repl` + +## nRepl +Use `make nrepl` command to fire up a nRepl process and connect to it using `netcat` or something +similar. If you're using Emacs, there is a `serene-mode` available that distributes as part of +[FG42](https://gitlab.com/FG42/FG42/blob/master/lib/extensions/serene/serene-simple-mode.el). + +Serene's nRepl is super simple. It waits for a newline char and then evaluates the +given input. It sends back the result of the evaluation in `` format. +`status-char` is either `0` or `1`. **Zero** means the evaluation was successful and the `value` +is the result of evaluation while **one** means there was an error during the evaluation and +the `value` is the traceback for the exception. diff --git a/src/main/java/serene/simple/Main.java b/src/main/java/serene/simple/Main.java index cdf0d3e..ccf4696 100644 --- a/src/main/java/serene/simple/Main.java +++ b/src/main/java/serene/simple/Main.java @@ -115,6 +115,13 @@ public class Main { } } + /** + * Serene's nRepl is super simple. It waits for a newline char and then evaluates the + * given input. It sends back the result of the evaluation in `` format. + * `status-char` is either `0` or `1`. **Zero** means the evaluation was successful and the `value` + * is the result of evaluation while **one** means there was an error during the evaluation and + * the `value` is the traceback for the exception. + */ public static void nrepl() throws IOException { RootScope rootScope = new RootScope(); ServerSocket socket = new ServerSocket(Main.port);; @@ -124,6 +131,8 @@ public class Main { System.out.println( String.format("nRepl has been started on tcp://%s:%s", Main.host, Main.port)); + // NOTE: The nRepl server is too simple. It supports one connection at a time + // and will terminate when the client disconnects. try { Socket clientSocket = socket.accept();