One of Arcadia's most exciting features is its ability to livecode Unity. This is enabled by Clojure which, as a member of the Lisp family of programming languages, is designed with a Read Evaluate Print Loop (or REPL) in mind. The function of a REPL is to
- Read incoming source code, turning text into expressions
- Evaluate new expressions, producing values, creating new functions, or effecting the state of the application
- Print the results back to the programmer
- Loop back to the first step, waiting for more code
The evaluated code can be as large as a whole file, or as small as an individual expression. The REPL is used to incrementally sculpt your game while developing it, to query the state of things while debugging, to put on livecoding performances, and much more.
Arcadia includes two REPL servers: Clojure's standard socket server provided by the
clojure.core.server namespace listening on port 37220, and a basic implementation of an nREPL server listening on port 3722. The socket server is simple and easy to integrate into new environments while nREPL is somewhat more involved but has more tooling built for it in the Clojure ecosystem.
The nREPL current implementation is very basic and only supports evaluation, so the IDE-like features of e.g. cider will not work. Furthermore, Arcadia's breakpoint system currently only works with the socket server REPL and not nREPL.
There are (at least) three routes to Emacs integration.
cider via nREPL
Arcadia's nREPL implementation usable from cider, though many of the more advanced IDE-like features are not yet supported.
- Install cider normally.
- Follow the instruction to connect to a running nREPL server, providing
localhostas the host and 3722 as the port.
Miracle via nREPL
By using Miracle you gain access to jump to definition and describe var, and more!
- Install the miracle package, making sure to follow all the installation steps.
M-x miracleand connect to
inf-clojure via socket-repl
- Install the inf-clojure package, and follow the instructions on its repo for activating it for Clojure files.
- Place the following snippet in your
.initfile, or wherever else it's likely to be evaluated on Emacs startup.
(require 'inf-clojure) (defcustom arcadia-repl-port 37220 "Port to connect to Arcadia repl.") (defun arcadia-repl () "Attempts to connect to a running Arcadia instance over the Arcadia socket-repl." (interactive) (inf-clojure-connect "localhost" arcadia-repl-port)) ;; inf-clojure's argslists eldoc support spams the Arcadia repl ;; and slows down Emacs. This (removable) empty wrapper function is a ;; quick kludge to disable it. (defun arcadia-inf-clojure-eldoc-setup-wrapper (orig-fun &rest args) ) ;; hack that disables eldoc for inf-clojure. (advice-add 'inf-clojure-eldoc-setup :around #'arcadia-inf-clojure-eldoc-setup-wrapper)
- With this in place, type
M-x arcadia-replto connect via an
inf-clojureREPL once Arcadia is running in Unity. Most
inf-clojurecommands should work as normal.
If you don't use inf-clojure for anything other than Arcadia, the following might also be desirable for less spurious error output related to automatic repl detection. See the docstring for inf-clojure-repl-type for details and another possible approach.
(defun arcadia-set-repl-type () (setq-local inf-clojure-repl-type 'clojure)) (add-hook 'inf-clojure-mode-hook #'arcadia-set-repl-type)
Arcadia's nREPL implementation is usable from vim-fireplace
- Install vim-fireplace, skipping the setup of cider-nrepl
- Start editing a Clojure file
- Use the
:Connectcommand and provide
localhostas the host and 3722 as the port
Arcadia's nREPL implementation is usable from proto-repl.
- Install the
- In the
proto-replsettings, uncheck Enable Completions and Refresh On Repl Start. These do not work with Arcadia yet.
- Restart Atom for the changes to take effect
- Connect to Arcadia with the
Proto Repl: Remote Nrepl Connectioncommand, using 3722 as the port and leaving the host as
Arcadia's nREPL implementation is usable with the https://notabug.org/selfsame/arcadia-repl package:
- Open Sublime's User packages directory, clone the
- Right Click and select
Start Arcadia NREPLfrom context menu
Alt+Enterto evaluate top level forms, full key list here.
In the absence of an editor the socket server REPL is usable from the command line via telnet
$ telnet localhost 37220 Trying ::1... Connected to localhost. Escape character is '^]'. user=>