{"id":1032,"date":"2024-12-17T12:15:23","date_gmt":"2024-12-17T12:15:23","guid":{"rendered":"https:\/\/monkey.ploogie.co.uk\/?page_id=1032"},"modified":"2025-10-01T13:48:07","modified_gmt":"2025-10-01T12:48:07","slug":"the-mwnci-repl","status":"publish","type":"page","link":"https:\/\/monkey.ploogie.co.uk\/index.php\/the-mwnci-repl\/","title":{"rendered":"The Mwnci REPL"},"content":{"rendered":"<p>REPL stands for \u201cRead Eval Print Loop&#8221;. Basically it&#8217;s the <i>console<\/i> for evaluating Mwnci commands.<\/p>\n<p>The REPL reads input, sends it to the interpreter for evaluation, prints the result\/output of the interpreter and starts again. <strong>R<\/strong>ead, <strong>E<\/strong>val, <strong>P<\/strong>rint, <strong>L<\/strong>oop.<\/p>\n<p>To start with the REPL, just type <i>mwnci<\/i> and press enter<\/p>\n<pre>\r\nnobby@reggie> mwnci\r\nMwnci v0.2.13 (linux arm64)\r\nmwnci>\r\n<\/pre>\n<p>If all is well, then you will see something similar to the above, with the cursor waiting patiently at the end of <i>mwnci><\/i><\/p>\n<p>We can now enter our first command, so we&#8217;ll start with the standard &#8220;Hello World&#8221;<\/p>\n<pre>\r\nMwnci v0.2.13 (linux arm64)\r\nmwnci> println(\"Hello World\")\r\nmwnci>  \r\n<\/pre>\n<p>And majestically, another prompt appears. So where&#8217;s the output?<br \/>\nDue to a (very) bad decision by the author, a command or group of commands needs to be delimited by a colon (:) before anything is evaluated (executed).<\/p>\n<pre>\r\nMwnci 0.1.9.r14-20241208-042504\r\nmwnci> println(\"Hello World\")\r\nmwnci> :\r\nHello World\r\nnull\r\nmwnci>\r\n<\/pre>\n<p>The last return value is also shown. In this case it&#8217;s <i>null<\/i> because the <i>println<\/i> command doesn&#8217;t need a return response other than output the requested text.<\/p>\n<p>The colon doesn&#8217;t need to be on a separate line.<\/p>\n<pre>\r\nMwnci 0.1.9.r14-20241208-042504\r\nmwnci> println(\"Hello World\")\r\nmwnci> :\r\nHello World\r\nnull\r\nmwnci> println(\"Hello World\"):\r\nHello World\r\nnull\r\n<\/pre>\n<p>Now we can show how the colon works after entering several <i>mwnci<\/i> commands<\/p>\n<pre>\r\nmwnci> foreach n in 1..10 {\r\nmwnci> println(n)\r\nmwnci> }:\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\nnull\r\nmwnci>\r\n<\/pre>\n<p>There is command line history for the REPL, using <i>emacs<\/i> bindings. So if you us the up arrow you can go back a line at a time.  In this case a line is the succession of commands prior to the last colon. So if we press the up arrow you will see<\/p>\n<pre>\r\nmwnci> foreach n in 1..10 {\r\nmwnci> println(n)\r\nmwnci> }:\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\nnull\r\nmwnci> foreach n in 1..10 { println(n) }\r\n<\/pre>\n<p>To exit the REPL and get back to the command line<\/p>\n<pre>\r\nmwnci> exit():\r\nnobby@reggie>\r\n<\/pre>\n<p>Or just type the keyboard combination  <code>Ctrl-C<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>REPL stands for \u201cRead Eval Print Loop&#8221;. Basically it&#8217;s the console for evaluating Mwnci commands. The REPL reads input, sends it to the interpreter for evaluation, prints the result\/output of the interpreter and starts again. Read, Eval, Print, Loop. To start with the REPL, just type mwnci and press enter nobby@reggie> mwnci Mwnci v0.2.13 (linux &hellip; <a href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/the-mwnci-repl\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;The Mwnci REPL&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1032","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1032","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=1032"}],"version-history":[{"count":15,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1032\/revisions"}],"predecessor-version":[{"id":1233,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1032\/revisions\/1233"}],"wp:attachment":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=1032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}