![]() There are several different REPL options with ClojureScript, but we will be using Figwheel throughout this book. Remember that the ClojureScript REPL is only in charge or the Read and Print portions, and it needs a browser to perform the Eval step, so if you kill the browser, the REPL will not be able to evaluate anything else until you open a browser that it can connect to again. This loop continues until the REPL is killed or the browser that it is connected to is closed. Finally, the REPL prints the result and waits for more input from the user. Once the browser evaluates the JavaScript code, it sends the result back to the REPL. Once we have input a ClojureScript expression, it compiles the expression to JavaScript and sends the JavaScript code to a web browser (via a WebSocket) to be evaluated. This process is illustrated in the figure below:įirst, the REPL waits for input from the user. Learn how the REPL interacts with a web browserĪs we mentioned above, REPL stands for Read-Eval-Print Loop because it Reads each expression that we type at the prompt, Evaluates that expression in the context of a web browser, Prints the result of that expression back at our command line.Use Figwheel’s REPL to experiment with new code.Understand what a REPL is and to use it.However, unlike unit tests, the REPL is more interactive and provides even quicker feedback. ![]() Just like unit tests, REPL development allows us to test a piece of code in isolation, examining its output and making sure that it matches our expectations. ![]() While live reloading is a great help when we already have a good idea of the code we need to write, the REPL gives us an environment for writing more exploratory code - trying out ideas and algorithms before making them part of our project. In this lesson, we will take a first look into a tool called a REPL, which stands for Read-Eval-Print Loop and is conceptually similar to the JavaScript console that most browsers provide. In the previous lesson, we learned how to use Figwheel to reload code whenever a source file changed, enabling a very quick feedback cycle. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |