diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-09 00:24:24 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-09 00:24:24 -0700 |
commit | b4d5b58959f9d416976910609f46733ee91bacb0 (patch) | |
tree | 3293be48d95f44481ae2b0cf151099ccf112898f | |
parent | ceeb92d470c29613f6a036f9c2077126ecc09b47 (diff) | |
download | mu-b4d5b58959f9d416976910609f46733ee91bacb0.tar.gz |
3491
Update the html, proving that commit 3490 worked. The only changes are from other recent commits.
-rw-r--r-- | html/069hash.cc.html | 4 | ||||
-rw-r--r-- | html/091socket.cc.html | 99 | ||||
-rw-r--r-- | html/092socket.mu.html | 155 | ||||
-rw-r--r-- | html/channel.mu.html | 4 | ||||
-rw-r--r-- | html/chessboard.mu.html | 68 | ||||
-rw-r--r-- | html/console.mu.html | 2 | ||||
-rw-r--r-- | html/edit/002-typing.mu.html | 2 | ||||
-rw-r--r-- | html/edit/004-programming-environment.mu.html | 6 | ||||
-rw-r--r-- | html/factorial.mu.html | 2 | ||||
-rw-r--r-- | html/filesystem.mu.html | 2 | ||||
-rw-r--r-- | html/http-server.mu.html (renamed from html/server-socket.mu.html) | 34 | ||||
-rw-r--r-- | html/lambda-to-mu.mu.html | 120 | ||||
-rw-r--r-- | html/nqueens.mu.html | 20 | ||||
-rw-r--r-- | html/real-files.mu.html | 2 | ||||
-rw-r--r-- | html/tangle.mu.html | 2 |
15 files changed, 347 insertions, 175 deletions
diff --git a/html/069hash.cc.html b/html/069hash.cc.html index c71609da..8025c2cc 100644 --- a/html/069hash.cc.html +++ b/html/069hash.cc.html @@ -71,7 +71,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">size_t</span> hash<span class="Delimiter">(</span><span class="Normal">size_t</span> h<span class="Delimiter">,</span> reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> r<span class="Delimiter">)</span> <span class="Delimiter">{</span> canonize<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_text<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Comment">// optimization</span> - <span class="Identifier">return</span> hash_mu_string<span class="Delimiter">(</span>h<span class="Delimiter">,</span> r<span class="Delimiter">);</span> + <span class="Identifier">return</span> hash_mu_text<span class="Delimiter">(</span>h<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_address<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Identifier">return</span> hash_mu_address<span class="Delimiter">(</span>h<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_scalar<span class="Delimiter">(</span>r<span class="Delimiter">))</span> @@ -102,7 +102,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Identifier">return</span> hash<span class="Delimiter">(</span>h<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">size_t</span> hash_mu_string<span class="Delimiter">(</span><span class="Normal">size_t</span> h<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">size_t</span> hash_mu_text<span class="Delimiter">(</span><span class="Normal">size_t</span> h<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> string input = read_mu_text<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> r<span class="Delimiter">.</span>value<span class="Delimiter">));</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>input<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> h = hash_iter<span class="Delimiter">(</span>h<span class="Delimiter">,</span> <span class="Normal">static_cast</span><<span class="Normal">size_t</span>><span class="Delimiter">(</span>input<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)));</span> diff --git a/html/091socket.cc.html b/html/091socket.cc.html index d01a297f..32f19c2e 100644 --- a/html/091socket.cc.html +++ b/html/091socket.cc.html @@ -32,11 +32,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </head> <body> <pre id='vimCodeElement'> -<span class="Delimiter">:(before "End Includes")</span> -<span class="PreProc">#include </span><span class="Constant"><unistd.h></span> -<span class="PreProc">#include </span><span class="Constant"><sys/socket.h></span> -<span class="PreProc">#include </span><span class="Constant"><netinet/in.h></span> - <span class="Delimiter">:(before "End Types")</span> <span class="Normal">struct</span> socket_t <span class="Delimiter">{</span> <span class="Normal">int</span> fd<span class="Delimiter">;</span> @@ -47,52 +42,34 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Delimiter">};</span> -<span class="Delimiter">:(code)</span> -<span class="Normal">void</span> server_socket<span class="Delimiter">(</span><span class="Normal">int</span> portno<span class="Delimiter">,</span> socket_t* server<span class="Delimiter">)</span> <span class="Delimiter">{</span> - server<span class="Delimiter">-></span>fd = socket<span class="Delimiter">(</span>AF_INET<span class="Delimiter">,</span> SOCK_STREAM<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Normal">int</span> dummy = <span class="Constant">0</span><span class="Delimiter">;</span> - setsockopt<span class="Delimiter">(</span>server<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> SOL_SOCKET<span class="Delimiter">,</span> SO_REUSEADDR<span class="Delimiter">,</span> &dummy<span class="Delimiter">,</span> <span class="Normal">sizeof</span><span class="Delimiter">(</span>dummy<span class="Delimiter">));</span> - server<span class="Delimiter">-></span>addr<span class="Delimiter">.</span>sin_family = AF_INET<span class="Delimiter">;</span> - server<span class="Delimiter">-></span>addr<span class="Delimiter">.</span>sin_addr<span class="Delimiter">.</span>s_addr = INADDR_ANY<span class="Delimiter">;</span> - server<span class="Delimiter">-></span>addr<span class="Delimiter">.</span>sin_port = htons<span class="Delimiter">(</span>portno<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>bind<span class="Delimiter">(</span>server<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> <span class="Delimiter">(</span><span class="Normal">struct</span> sockaddr*<span class="Delimiter">)</span>&server<span class="Delimiter">-></span>addr<span class="Delimiter">,</span> <span class="Normal">sizeof</span><span class="Delimiter">(</span>server<span class="Delimiter">-></span>addr<span class="Delimiter">))</span> < <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - close<span class="Delimiter">(</span>server<span class="Delimiter">-></span>fd<span class="Delimiter">);</span> - server<span class="Delimiter">-></span>fd = -<span class="Constant">1</span><span class="Delimiter">;</span> - raise << <span class="Constant">"Failed to bind server socket to port "</span> << portno << <span class="Constant">". Something's already using that port.</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> - <span class="Identifier">return</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> - listen<span class="Delimiter">(</span>server<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">queue length</span><span class="Comment">*/</span><span class="Constant">5</span><span class="Delimiter">);</span> -<span class="Delimiter">}</span> - <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> -_SOCKET<span class="Delimiter">,</span> +_OPEN_SERVER_SOCKET<span class="Delimiter">,</span> <span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> -put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"$socket"</span><span class="Delimiter">,</span> _SOCKET<span class="Delimiter">);</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"$open-server-socket"</span><span class="Delimiter">,</span> _OPEN_SERVER_SOCKET<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> -<span class="Normal">case</span> _SOCKET: <span class="Delimiter">{</span> +<span class="Normal">case</span> _OPEN_SERVER_SOCKET: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'$socket' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'$open-server-socket' requires exactly one ingredient (the port to listen for requests on), but got '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of '$socket' should be a number, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of '$open-server-socket' should be a number, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'$socket' requires exactly one product, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'$open-server-socket' requires exactly one product, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first product of '$socket' should be a number (file handle), but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first product of '$open-server-socket' should be a number (file handle), but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> -<span class="Normal">case</span> _SOCKET: <span class="Delimiter">{</span> +<span class="Normal">case</span> _OPEN_SERVER_SOCKET: <span class="Delimiter">{</span> <span class="Normal">int</span> port = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> - socket_t* server = <span class="Normal">new</span> socket_t<span class="Delimiter">();</span> - server_socket<span class="Delimiter">(</span>port<span class="Delimiter">,</span> server<span class="Delimiter">);</span> + socket_t* server = server_socket<span class="Delimiter">(</span>port<span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>server<span class="Delimiter">-></span>fd < <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">delete</span> server<span class="Delimiter">;</span> @@ -103,12 +80,31 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Normal">static_cast</span><<span class="Normal">double</span>><span class="Delimiter">(</span>result<span class="Delimiter">));</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Delimiter">:(code)</span> -<span class="Normal">void</span> session_socket<span class="Delimiter">(</span><span class="Normal">int</span> serverfd<span class="Delimiter">,</span> socket_t* session<span class="Delimiter">)</span> <span class="Delimiter">{</span> - socklen_t dummy = <span class="Normal">sizeof</span><span class="Delimiter">(</span>session<span class="Delimiter">-></span>addr<span class="Delimiter">);</span> - session<span class="Delimiter">-></span>fd = accept<span class="Delimiter">(</span>serverfd<span class="Delimiter">,</span> <span class="Delimiter">(</span><span class="Normal">struct</span> sockaddr*<span class="Delimiter">)</span>&session<span class="Delimiter">-></span>addr<span class="Delimiter">,</span> &dummy<span class="Delimiter">);</span> +socket_t* server_socket<span class="Delimiter">(</span><span class="Normal">int</span> port<span class="Delimiter">)</span> <span class="Delimiter">{</span> + socket_t* result = <span class="Normal">new</span> socket_t<span class="Delimiter">;</span> + result<span class="Delimiter">-></span>fd = socket<span class="Delimiter">(</span>AF_INET<span class="Delimiter">,</span> SOCK_STREAM<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">-></span>fd < <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise << <span class="Constant">"Failed to create server socket.</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Normal">delete</span> result<span class="Delimiter">;</span> + <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Normal">int</span> dummy = <span class="Constant">0</span><span class="Delimiter">;</span> + setsockopt<span class="Delimiter">(</span>result<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> SOL_SOCKET<span class="Delimiter">,</span> SO_REUSEADDR<span class="Delimiter">,</span> &dummy<span class="Delimiter">,</span> <span class="Normal">sizeof</span><span class="Delimiter">(</span>dummy<span class="Delimiter">));</span> + result<span class="Delimiter">-></span>addr<span class="Delimiter">.</span>sin_family = AF_INET<span class="Delimiter">;</span> + result<span class="Delimiter">-></span>addr<span class="Delimiter">.</span>sin_addr<span class="Delimiter">.</span>s_addr = INADDR_ANY<span class="Delimiter">;</span> + result<span class="Delimiter">-></span>addr<span class="Delimiter">.</span>sin_port = htons<span class="Delimiter">(</span>port<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>bind<span class="Delimiter">(</span>result<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> <span class="Normal">reinterpret_cast</span><sockaddr*><span class="Delimiter">(</span>&result<span class="Delimiter">-></span>addr<span class="Delimiter">),</span> <span class="Normal">sizeof</span><span class="Delimiter">(</span>result<span class="Delimiter">-></span>addr<span class="Delimiter">))</span> >= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + listen<span class="Delimiter">(</span>result<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">queue length</span><span class="Comment">*/</span><span class="Constant">5</span><span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Normal">else</span> <span class="Delimiter">{</span> + close<span class="Delimiter">(</span>result<span class="Delimiter">-></span>fd<span class="Delimiter">);</span> + result<span class="Delimiter">-></span>fd = -<span class="Constant">1</span><span class="Delimiter">;</span> + raise << <span class="Constant">"Failed to bind result socket to port "</span> << port << <span class="Constant">". Something's already using that port.</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> + <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> _ACCEPT<span class="Delimiter">,</span> <span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> @@ -135,16 +131,28 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> _ACCEPT: <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> x = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - socket_t* socket = <span class="Normal">reinterpret_cast</span><socket_t*><span class="Delimiter">(</span>x<span class="Delimiter">);</span> - socket_t* session = <span class="Normal">new</span> socket_t<span class="Delimiter">();</span> - session_socket<span class="Delimiter">(</span>socket<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> session<span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Normal">reinterpret_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>session<span class="Delimiter">);</span> - products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Normal">static_cast</span><<span class="Normal">double</span>><span class="Delimiter">(</span>result<span class="Delimiter">));</span> - products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> <span class="Comment">// indicate it modifies its ingredient</span> + <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> x = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + socket_t* server = <span class="Normal">reinterpret_cast</span><socket_t*><span class="Delimiter">(</span>x<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>server<span class="Delimiter">)</span> <span class="Delimiter">{</span> + socket_t* session = accept_session<span class="Delimiter">(</span>server<span class="Delimiter">);</span> + <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Normal">reinterpret_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>session<span class="Delimiter">);</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Normal">static_cast</span><<span class="Normal">double</span>><span class="Delimiter">(</span>result<span class="Delimiter">));</span> + <span class="Delimiter">}</span> + <span class="Normal">else</span> <span class="Delimiter">{</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="Delimiter">:(code)</span> +socket_t* accept_session<span class="Delimiter">(</span>socket_t* server<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>server<span class="Delimiter">-></span>fd == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span> + socket_t* result = <span class="Normal">new</span> socket_t<span class="Delimiter">;</span> + socklen_t dummy = <span class="Normal">sizeof</span><span class="Delimiter">(</span>result<span class="Delimiter">-></span>addr<span class="Delimiter">);</span> + result<span class="Delimiter">-></span>fd = accept<span class="Delimiter">(</span>server<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> <span class="Normal">reinterpret_cast</span><sockaddr*><span class="Delimiter">(</span>&result<span class="Delimiter">-></span>addr<span class="Delimiter">),</span> &dummy<span class="Delimiter">);</span> + <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> _READ_FROM_SOCKET<span class="Delimiter">,</span> @@ -238,6 +246,11 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span close<span class="Delimiter">(</span>socket<span class="Delimiter">-></span>fd<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> + +<span class="Delimiter">:(before "End Includes")</span> +<span class="PreProc">#include </span><span class="Constant"><netinet/in.h></span> +<span class="PreProc">#include </span><span class="Constant"><sys/socket.h></span> +<span class="PreProc">#include </span><span class="Constant"><unistd.h></span> </pre> </body> </html> diff --git a/html/092socket.mu.html b/html/092socket.mu.html new file mode 100644 index 00000000..197e72cb --- /dev/null +++ b/html/092socket.mu.html @@ -0,0 +1,155 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - 092socket.mu</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> +<meta name="syntax" content="none"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } +body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.muData { color: #ffff00; } +.muControl { color: #c0a020; } +.Delimiter { color: #800080; } +.Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Comment"># Wrappers around socket primitives that take a 'local-network' object and are</span> +<span class="Comment"># thus easier to test.</span> +<span class="Comment">#</span> +<span class="Comment"># The current semantics of fake port-connections don't match UNIX socket ones,</span> +<span class="Comment"># but we'll improve them as we learn more.</span> + +<span class="muData">container</span> local-network [ + data:&:@:port-connection +] + +<span class="Comment"># Port connections represent connections to ports on localhost.</span> +<span class="Comment"># Before passing a local-network object to network functions</span> +<span class="Comment"># `start-reading-socket` and `start-writing-socket`, add port-connections to</span> +<span class="Comment"># the local-network.</span> +<span class="Comment">#</span> +<span class="Comment"># For reading, `transmit-from-socket` will check for a</span> +<span class="Comment"># port-connection on the port parameter that's been passed in. If there's</span> +<span class="Comment"># no port-connectin for that port, it will return nothing and log. If</span> +<span class="Comment"># there is a port-connection for that port, it will transmit the contents</span> +<span class="Comment"># to the passed in sink.</span> +<span class="Comment">#</span> +<span class="Comment"># For writing, `start-writing-socket` returns a sink connecting the</span> +<span class="Comment"># caller to the socket on the passed-in port.</span> +<span class="muData">container</span> port-connection [ + port:num + contents:text +] + +<span class="muRecipe">def</span> new-port-connection port:num, contents:text<span class="muRecipe"> -> </span>p:&:port-connection [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + p:&:port-connection<span class="Special"> <- </span>new <span class="Constant">port-connection:type</span> + *p<span class="Special"> <- </span>merge port, contents +] + +<span class="muRecipe">def</span> new-fake-network<span class="muRecipe"> -> </span>n:&:local-network [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + n:&:local-network<span class="Special"> <- </span>new <span class="Constant">local-network:type</span> + local-network-ports:&:@:port-connection<span class="Special"> <- </span>new <span class="Constant">port-connection:type</span>, <span class="Constant">0</span> + *n<span class="Special"> <- </span>put *n, <span class="Constant">data:offset</span>, local-network-ports +] + +<span class="muScenario">scenario</span> write-to-fake-socket [ + <span class="Constant">local-scope</span> + single-port-network:&:local-network<span class="Special"> <- </span>new-fake-network + sink:&:sink:char, writer:num/routine<span class="Special"> <- </span>start-writing-socket single-port-network, <span class="Constant">8080</span> + sink<span class="Special"> <- </span>write sink, <span class="Constant">120/x</span> + close sink + wait-for-routine writer + tested-port-connections:&:@:port-connection<span class="Special"> <- </span>get *single-port-network, <span class="Constant">data:offset</span> + tested-port-connection:port-connection<span class="Special"> <- </span>index *tested-port-connections, <span class="Constant">0</span> + contents:text<span class="Special"> <- </span>get tested-port-connection, <span class="Constant">contents:offset</span> + <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *contents + memory-should-contain [ + <span class="Constant">10</span>:array:character<span class="Special"> <- </span><span class="Constant">[x]</span> + ] +] + +<span class="muRecipe">def</span> start-writing-socket network:&:local-network, port:num<span class="muRecipe"> -> </span>sink:&:sink:char, routine-id:num [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + source:&:source:char, sink:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">30</span> + <span class="Delimiter">{</span> + <span class="muControl">break-if</span> network + socket:num<span class="Special"> <- </span>$open-server-socket port + session:num<span class="Special"> <- </span>$accept socket + <span class="Comment"># TODO Create channel implementation of write-to-socket.</span> + <span class="muControl">return</span> sink, <span class="Constant">0/routine-id</span> + <span class="Delimiter">}</span> + <span class="Comment"># fake network</span> + routine-id<span class="Special"> <- </span>start-running transmit-to-fake-socket network, port, source +] + +<span class="muRecipe">def</span> transmit-to-fake-socket network:&:local-network, port:num, source:&:source:char<span class="muRecipe"> -> </span>network:&:local-network, source:&:source:char [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + <span class="Comment"># compute new port connection contents</span> + buf:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> + <span class="Delimiter">{</span> + c:char, done?:bool, source<span class="Special"> <- </span>read source + <span class="muControl">break-unless</span> c + buf<span class="Special"> <- </span>append buf, c + <span class="muControl">break-if</span> done? + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + contents:text<span class="Special"> <- </span>buffer-to-array buf + new-port-connection:&:port-connection<span class="Special"> <- </span>new-port-connection port, contents + <span class="Comment"># Got the contents of the channel, time to write to fake port.</span> + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + port-connections:&:@:port-connection<span class="Special"> <- </span>get *network, <span class="Constant">data:offset</span> + len:num<span class="Special"> <- </span>length *port-connections + <span class="Delimiter">{</span> + done?:bool<span class="Special"> <- </span>greater-or-equal i, len + <span class="muControl">break-if</span> done? + current:port-connection<span class="Special"> <- </span>index *port-connections, i + current-port:num<span class="Special"> <- </span>get current, <span class="Constant">port:offset</span> + ports-match?:bool<span class="Special"> <- </span>equal current-port, port + i<span class="Special"> <- </span>add i, <span class="Constant">1</span> + <span class="muControl">loop-unless</span> ports-match? + <span class="Comment"># Found an existing connection on this port, overwrite.</span> + put-index *port-connections, i, *new-port-connection + <span class="muControl">reply</span> + <span class="Delimiter">}</span> + <span class="Comment"># Couldn't find an existing connection on this port, initialize a new one.</span> + new-len:num<span class="Special"> <- </span>add len, <span class="Constant">1</span> + new-port-connections:&:@:port-connection<span class="Special"> <- </span>new <span class="Constant">port-connection:type</span>, new-len + put *network, <span class="Constant">data:offset</span>, new-port-connections + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Delimiter">{</span> + done?:bool<span class="Special"> <- </span>greater-or-equal i, len + <span class="muControl">break-if</span> done? + tmp:port-connection<span class="Special"> <- </span>index *port-connections, i + put-index *new-port-connections, i, tmp + <span class="Delimiter">}</span> + put-index *new-port-connections, len, *new-port-connection +] +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/channel.mu.html b/html/channel.mu.html index 0e0bdffb..3970a8c2 100644 --- a/html/channel.mu.html +++ b/html/channel.mu.html @@ -39,7 +39,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># n = 0</span> n:char<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>lesser-than n, <span class="Constant">5</span> + done?:bool<span class="Special"> <- </span>lesser-than n, <span class="Constant">5</span> <span class="muControl">break-unless</span> done? <span class="Comment"># other threads might get between these prints</span> $print <span class="Constant">[produce: ]</span>, n, <span class="Constant">[ </span> @@ -57,7 +57,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> <span class="Comment"># read an integer from the channel</span> - n:char, eof?:boolean, source<span class="Special"> <- </span>read source + n:char, eof?:bool, source<span class="Special"> <- </span>read source <span class="muControl">break-if</span> eof? <span class="Comment"># other threads might get between these prints</span> $print <span class="Constant">[consume: ]</span>, n:char, <span class="Constant">[ </span> diff --git a/html/chessboard.mu.html b/html/chessboard.mu.html index 8e15aa53..891cdd93 100644 --- a/html/chessboard.mu.html +++ b/html/chessboard.mu.html @@ -124,7 +124,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> cursor-to-next-line screen screen<span class="Special"> <- </span>print screen, <span class="Constant">[move: ]</span> - m:&:move, quit:boolean, error:boolean<span class="Special"> <- </span>read-move buffered-stdin-in, screen + m:&:move, quit:bool, error:bool<span class="Special"> <- </span>read-move buffered-stdin-in, screen <span class="muControl">break-if</span> quit, <span class="Constant">+quit:label</span> buffered-stdin-in<span class="Special"> <- </span>clear buffered-stdin-in <span class="Comment"># cleanup after error. todo: test this?</span> <span class="muControl">loop-if</span> error @@ -143,13 +143,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> <span class="Comment"># assert(length(initial-position) == 64)</span> len:num<span class="Special"> <- </span>length *initial-position - correct-length?:boolean<span class="Special"> <- </span>equal len, <span class="Constant">64</span> + correct-length?:bool<span class="Special"> <- </span>equal len, <span class="Constant">64</span> assert correct-length?, <span class="Constant">[chessboard had incorrect size]</span> <span class="Comment"># board is an array of pointers to files; file is an array of characters</span> board<span class="Special"> <- </span>new <span class="Delimiter">{</span>(address array character): type<span class="Delimiter">}</span>, <span class="Constant">8</span> col:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>equal col, <span class="Constant">8</span> + done?:bool<span class="Special"> <- </span>equal col, <span class="Constant">8</span> <span class="muControl">break-if</span> done? file:&:@:char<span class="Special"> <- </span>new-file initial-position, col *board<span class="Special"> <- </span>put-index *board, col, file @@ -165,7 +165,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color result<span class="Special"> <- </span>new <span class="Constant">character:type</span>, <span class="Constant">8</span> row:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>equal row, <span class="Constant">8</span> + done?:bool<span class="Special"> <- </span>equal row, <span class="Constant">8</span> <span class="muControl">break-if</span> done? square:char<span class="Special"> <- </span>index *position, index *result<span class="Special"> <- </span>put-index *result, row, square @@ -182,7 +182,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> <span class="Comment"># print each row</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>lesser-than row, <span class="Constant">0</span> + done?:bool<span class="Special"> <- </span>lesser-than row, <span class="Constant">0</span> <span class="muControl">break-if</span> done? <span class="Comment"># print rank number as a legend</span> rank:num<span class="Special"> <- </span>add row, <span class="Constant">1</span> @@ -191,8 +191,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># print each square in the row</span> col:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>equal col:num, <span class="Constant">8</span> - <span class="muControl">break-if</span> done?:boolean + done?:bool<span class="Special"> <- </span>equal col:num, <span class="Constant">8</span> + <span class="muControl">break-if</span> done?:bool f:&:@:char<span class="Special"> <- </span>index *board, col c:char<span class="Special"> <- </span>index *f, row print screen, c @@ -269,10 +269,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># prints only error messages to screen</span> -<span class="muRecipe">def</span> read-move stdin:&:source:char, screen:&:screen<span class="muRecipe"> -> </span>result:&:move, quit?:boolean, error?:boolean, stdin:&:source:char, screen:&:screen [ +<span class="muRecipe">def</span> read-move stdin:&:source:char, screen:&:screen<span class="muRecipe"> -> </span>result:&:move, quit?:bool, error?:bool, stdin:&:source:char, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - from-file:num, quit?:boolean, error?:boolean<span class="Special"> <- </span>read-file stdin, screen + from-file:num, quit?:bool, error?:bool<span class="Special"> <- </span>read-file stdin, screen <span class="muControl">return-if</span> quit?, <span class="Constant">0/dummy</span> <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span> <span class="Comment"># construct the move object</span> @@ -285,8 +285,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color error?<span class="Special"> <- </span>expect-from-channel stdin, <span class="Constant">45/dash</span>, screen <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span> to-file:num, quit?, error?<span class="Special"> <- </span>read-file stdin, screen - <span class="muControl">return-if</span> quit?:boolean, <span class="Constant">0/dummy</span> - <span class="muControl">return-if</span> error?:boolean, <span class="Constant">0/dummy</span> + <span class="muControl">return-if</span> quit?:bool, <span class="Constant">0/dummy</span> + <span class="muControl">return-if</span> error?:bool, <span class="Constant">0/dummy</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">to-file:offset</span>, to-file to-rank:num, quit?, error?<span class="Special"> <- </span>read-rank stdin, screen <span class="muControl">return-if</span> quit?, <span class="Constant">0/dummy</span> @@ -297,13 +297,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># valid values for file: 0-7</span> -<span class="muRecipe">def</span> read-file stdin:&:source:char, screen:&:screen<span class="muRecipe"> -> </span>file:num, quit:boolean, error:boolean, stdin:&:source:char, screen:&:screen [ +<span class="muRecipe">def</span> read-file stdin:&:source:char, screen:&:screen<span class="muRecipe"> -> </span>file:num, quit:bool, error:bool, stdin:&:source:char, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - c:char, eof?:boolean, stdin<span class="Special"> <- </span>read stdin + c:char, eof?:bool, stdin<span class="Special"> <- </span>read stdin <span class="muControl">return-if</span> eof?, <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span> <span class="Delimiter">{</span> - q-pressed?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">81/Q</span> + q-pressed?:bool<span class="Special"> <- </span>equal c, <span class="Constant">81/Q</span> <span class="muControl">break-unless</span> q-pressed? <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span> <span class="Delimiter">}</span> @@ -313,12 +313,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - empty-fake-keyboard?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">0/eof</span> + empty-fake-keyboard?:bool<span class="Special"> <- </span>equal c, <span class="Constant">0/eof</span> <span class="muControl">break-unless</span> empty-fake-keyboard? <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? print screen, <span class="Constant">[that's not enough]</span> <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> @@ -326,7 +326,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color file:num<span class="Special"> <- </span>subtract c, <span class="Constant">97/a</span> <span class="Comment"># 'a' <= file <= 'h'</span> <span class="Delimiter">{</span> - above-min:boolean<span class="Special"> <- </span>greater-or-equal file, <span class="Constant">0</span> + above-min:bool<span class="Special"> <- </span>greater-or-equal file, <span class="Constant">0</span> <span class="muControl">break-if</span> above-min print screen, <span class="Constant">[file too low: ]</span> print screen, c @@ -334,7 +334,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - below-max:boolean<span class="Special"> <- </span>lesser-than file, <span class="Constant">8</span> + below-max:bool<span class="Special"> <- </span>lesser-than file, <span class="Constant">8</span> <span class="muControl">break-if</span> below-max print screen, <span class="Constant">[file too high: ]</span> print screen, c @@ -344,13 +344,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># valid values for rank: 0-7</span> -<span class="muRecipe">def</span> read-rank stdin:&:source:char, screen:&:screen<span class="muRecipe"> -> </span>rank:num, quit?:boolean, error?:boolean, stdin:&:source:char, screen:&:screen [ +<span class="muRecipe">def</span> read-rank stdin:&:source:char, screen:&:screen<span class="muRecipe"> -> </span>rank:num, quit?:bool, error?:bool, stdin:&:source:char, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - c:char, eof?:boolean, stdin<span class="Special"> <- </span>read stdin + c:char, eof?:bool, stdin<span class="Special"> <- </span>read stdin <span class="muControl">return-if</span> eof?, <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span> <span class="Delimiter">{</span> - q-pressed?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">8/Q</span> + q-pressed?:bool<span class="Special"> <- </span>equal c, <span class="Constant">8/Q</span> <span class="muControl">break-unless</span> q-pressed? <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span> <span class="Delimiter">}</span> @@ -360,7 +360,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10</span> <span class="Comment"># newline</span> + newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10</span> <span class="Comment"># newline</span> <span class="muControl">break-unless</span> newline? print screen, <span class="Constant">[that's not enough]</span> <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> @@ -368,14 +368,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color rank:num<span class="Special"> <- </span>subtract c, <span class="Constant">49/'1'</span> <span class="Comment"># assert'1' <= rank <= '8'</span> <span class="Delimiter">{</span> - above-min:boolean<span class="Special"> <- </span>greater-or-equal rank, <span class="Constant">0</span> + above-min:bool<span class="Special"> <- </span>greater-or-equal rank, <span class="Constant">0</span> <span class="muControl">break-if</span> above-min print screen, <span class="Constant">[rank too low: ]</span> print screen, c <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - below-max:boolean<span class="Special"> <- </span>lesser-or-equal rank, <span class="Constant">7</span> + below-max:bool<span class="Special"> <- </span>lesser-or-equal rank, <span class="Constant">7</span> <span class="muControl">break-if</span> below-max print screen, <span class="Constant">[rank too high: ]</span> print screen, c @@ -386,13 +386,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># read a character from the given channel and check that it's what we expect</span> <span class="Comment"># return true on error</span> -<span class="muRecipe">def</span> expect-from-channel stdin:&:source:char, expected:char, screen:&:screen<span class="muRecipe"> -> </span>result:boolean, stdin:&:source:char, screen:&:screen [ +<span class="muRecipe">def</span> expect-from-channel stdin:&:source:char, expected:char, screen:&:screen<span class="muRecipe"> -> </span>result:bool, stdin:&:source:char, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - c:char, eof?:boolean, stdin<span class="Special"> <- </span>read stdin + c:char, eof?:bool, stdin<span class="Special"> <- </span>read stdin <span class="muControl">return-if</span> eof? <span class="Constant">1/true</span> <span class="Delimiter">{</span> - match?:boolean<span class="Special"> <- </span>equal c, expected + match?:bool<span class="Special"> <- </span>equal c, expected <span class="muControl">break-if</span> match? print screen, <span class="Constant">[expected character not found]</span> <span class="Delimiter">}</span> @@ -408,7 +408,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state:num<span class="Special"> <- </span>routine-state read-move-routine - waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> + waiting?:bool<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-blocking: routine failed to pause after coming up (before any keys were pressed)]</span> <span class="Comment"># press 'a'</span> @@ -462,7 +462,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' now completes</span> wait-for-routine-to-block read-move-routine read-move-state<span class="Special"> <- </span>routine-state read-move-routine - completed?:boolean<span class="Special"> <- </span>equal read-move-state, <span class="Constant">1/completed</span> + completed?:bool<span class="Special"> <- </span>equal read-move-state, <span class="Constant">1/completed</span> assert completed?, <span class="Constant">[ </span> <span class="Constant">F read-move-blocking: routine failed to terminate on newline]</span> trace <span class="Constant">1</span>, <span class="Constant">[test]</span>, <span class="Constant">[reached end]</span> @@ -481,7 +481,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state:num<span class="Special"> <- </span>routine-state read-move-routine - waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> + waiting?:bool<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-quit: routine failed to pause after coming up (before any keys were pressed)]</span> <span class="Comment"># press 'q'</span> @@ -490,7 +490,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' completes</span> wait-for-routine-to-block read-move-routine read-move-state<span class="Special"> <- </span>routine-state read-move-routine - completed?:boolean<span class="Special"> <- </span>equal read-move-state, <span class="Constant">1/completed</span> + completed?:bool<span class="Special"> <- </span>equal read-move-state, <span class="Constant">1/completed</span> assert completed?, <span class="Constant">[ </span> <span class="Constant">F read-move-quit: routine failed to terminate on 'q']</span> trace <span class="Constant">1</span>, <span class="Constant">[test]</span>, <span class="Constant">[reached end]</span> @@ -509,7 +509,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state:num<span class="Special"> <- </span>routine-state read-move-routine - waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> + waiting?:bool<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-illegal-file: routine failed to pause after coming up (before any keys were pressed)]</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">50/'2'</span> @@ -531,7 +531,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state:num<span class="Special"> <- </span>routine-state read-move-routine - waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> + waiting?:bool<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-illegal-rank: routine failed to pause after coming up (before any keys were pressed)]</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">97/a</span> @@ -554,7 +554,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state:num<span class="Special"> <- </span>routine-state read-move-routine - waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> + waiting?:bool<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-empty: routine failed to pause after coming up (before any keys were pressed)]</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">10/newline</span> diff --git a/html/console.mu.html b/html/console.mu.html index 82b2d70f..f77fda40 100644 --- a/html/console.mu.html +++ b/html/console.mu.html @@ -38,7 +38,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> open-console <span class="Delimiter">{</span> - e:event, found?:boolean<span class="Special"> <- </span>check-for-interaction + e:event, found?:bool<span class="Special"> <- </span>check-for-interaction <span class="muControl">break-if</span> found? print-character-to-display <span class="Constant">97</span>, <span class="Constant">7/white</span> <span class="muControl">loop</span> diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index 8dd0fd48..256f1805 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -310,7 +310,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color row:num, column:num<span class="Special"> <- </span>render screen, editor clear-line-until screen, right row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - draw-horizontal screen, row, left, right, <span class="Constant">9548/horizontal-dashed</span> + draw-horizontal screen, row, left, right, <span class="Constant">9480/horizontal-dotted</span> row<span class="Special"> <- </span>add row, <span class="Constant">1</span> clear-screen-from screen, row, left, left, right ] diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 72fb4000..155ac14d 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -71,7 +71,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color print screen, <span class="Constant">[ run (F4) ]</span>, <span class="Constant">255/white</span>, <span class="Constant">161/reddish</span> <span class="Comment"># dotted line down the middle</span> divider:num, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> - draw-vertical screen, divider, <span class="Constant">1/top</span>, height, <span class="Constant">9550/vertical-dashed</span> + draw-vertical screen, divider, <span class="Constant">1/top</span>, height, <span class="Constant">9482/vertical-dotted</span> <span class="Comment"># recipe editor on the left</span> recipes:&:editor<span class="Special"> <- </span>new-editor initial-recipe-contents, screen, <span class="Constant">0/left</span>, divider/right <span class="Comment"># sandbox editor on the right</span> @@ -505,7 +505,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render divider]</span> divider:num, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> height:num<span class="Special"> <- </span>screen-height screen - draw-vertical screen, divider, <span class="Constant">1/top</span>, height, <span class="Constant">9550/vertical-dashed</span> + draw-vertical screen, divider, <span class="Constant">1/top</span>, height, <span class="Constant">9482/vertical-dotted</span> <span class="Comment">#</span> screen<span class="Special"> <- </span>render-recipes screen, env, render-editor screen<span class="Special"> <- </span>render-sandbox-side screen, env, render-editor @@ -532,7 +532,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color row<span class="Special"> <- </span>add row, <span class="Constant">1</span> <span class="Constant"> <render-recipe-components-end></span> <span class="Comment"># draw dotted line after recipes</span> - draw-horizontal screen, row, left, right, <span class="Constant">9548/horizontal-dashed</span> + draw-horizontal screen, row, left, right, <span class="Constant">9480/horizontal-dotted</span> row<span class="Special"> <- </span>add row, <span class="Constant">1</span> clear-screen-from screen, row, left, left, right ] diff --git a/html/factorial.mu.html b/html/factorial.mu.html index 43fcad16..a7deb772 100644 --- a/html/factorial.mu.html +++ b/html/factorial.mu.html @@ -45,7 +45,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> <span class="Comment"># if n=0 return 1</span> - zero?:boolean<span class="Special"> <- </span>equal n, <span class="Constant">0</span> + zero?:bool<span class="Special"> <- </span>equal n, <span class="Constant">0</span> <span class="muControl">break-unless</span> zero? <span class="muControl">return</span> <span class="Constant">1</span> <span class="Delimiter">}</span> diff --git a/html/filesystem.mu.html b/html/filesystem.mu.html index aaa31fe0..f25f8a2f 100644 --- a/html/filesystem.mu.html +++ b/html/filesystem.mu.html @@ -40,7 +40,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color source-file:&:source:char<span class="Special"> <- </span>start-reading <span class="Constant">0/real-filesystem</span>, <span class="Constant">[/tmp/mu-x]</span> sink-file:&:sink:char, write-routine:num<span class="Special"> <- </span>start-writing <span class="Constant">0/real-filesystem</span>, <span class="Constant">[/tmp/mu-y]</span> <span class="Delimiter">{</span> - c:char, done?:boolean, source-file<span class="Special"> <- </span>read source-file + c:char, done?:bool, source-file<span class="Special"> <- </span>read source-file <span class="muControl">break-if</span> done? sink-file<span class="Special"> <- </span>write sink-file, c <span class="muControl">loop</span> diff --git a/html/server-socket.mu.html b/html/http-server.mu.html index 18ce36d6..f3192ed5 100644 --- a/html/server-socket.mu.html +++ b/html/http-server.mu.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - server-socket.mu</title> +<title>Mu - http-server.mu</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> @@ -30,16 +30,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </head> <body> <pre id='vimCodeElement'> -<span class="Comment"># Example of reading from a socket using channels and writing back to it</span> -<span class="Comment"># directly. Running this file and navigating to <address of server>:8080</span> -<span class="Comment"># should result in your browser displaying "SUCCESS!".</span> +<span class="Comment"># example program: a single-request HTTP server</span> +<span class="Comment"># listen for connections from clients on a server socket</span> +<span class="Comment"># when a connection occurs, transfer it to a session socket</span> +<span class="Comment"># read from it using channels</span> +<span class="Comment"># write to it directly</span> <span class="Comment">#</span> -<span class="Comment"># Unfortunately, the reading implementation has some redundant, inelegant</span> -<span class="Comment"># code to make up for my lack of insight into Linux's socket internals.</span> +<span class="Comment"># After running it, navigate to localhost:8080. Your browser should display</span> +<span class="Comment"># "SUCCESS!" and the server will terminate after one connection.</span> + <span class="muRecipe">def</span> main [ <span class="Constant">local-scope</span> - socket:num<span class="Special"> <- </span>$socket <span class="Constant">8080/port</span> + socket:num<span class="Special"> <- </span>$open-server-socket <span class="Constant">8080/port</span> $print <span class="Constant">[Mu socket creation returned ]</span>, socket, <span class="Constant">10/newline</span> + <span class="muControl">return-unless</span> socket session:num<span class="Special"> <- </span>$accept socket contents:&:source:char, sink:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">30</span> sink<span class="Special"> <- </span>start-running transmit-from-socket session, sink @@ -62,15 +66,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color $close-socket socket ] -<span class="muRecipe">def</span> write-to-socket session-socket:number, s:address:array:character [ +<span class="muRecipe">def</span> write-to-socket session-socket:num, s:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - len:number<span class="Special"> <- </span>length *s - i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + len:num<span class="Special"> <- </span>length *s + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal i, len + done?:bool<span class="Special"> <- </span>greater-or-equal i, len <span class="muControl">break-if</span> done? - c:character<span class="Special"> <- </span>index *s, i + c:char<span class="Special"> <- </span>index *s, i $print <span class="Constant">[writing to socket: ]</span>, i, <span class="Constant">[ ]</span>, c, <span class="Constant">10/newline</span> $write-to-socket session-socket, c i<span class="Special"> <- </span>add i, <span class="Constant">1</span> @@ -82,11 +86,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> - req:text, bytes-read:number<span class="Special"> <- </span>$read-from-socket session, <span class="Constant">4096/bytes</span> + req:text, bytes-read:num<span class="Special"> <- </span>$read-from-socket session, <span class="Constant">4096/bytes</span> $print <span class="Constant">[read ]</span>, bytes-read, <span class="Constant">[ bytes from socket]</span>, <span class="Constant">10/newline</span> - i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal i, bytes-read + done?:bool<span class="Special"> <- </span>greater-or-equal i, bytes-read <span class="muControl">break-if</span> done? c:char<span class="Special"> <- </span>index *req, i end-of-request?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> diff --git a/html/lambda-to-mu.mu.html b/html/lambda-to-mu.mu.html index e591592b..52100115 100644 --- a/html/lambda-to-mu.mu.html +++ b/html/lambda-to-mu.mu.html @@ -83,14 +83,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *result<span class="Special"> <- </span>merge <span class="Constant">1/tag:pair</span>, a/first, b/rest ] -<span class="muRecipe">def</span> is-atom? x:&:cell<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> is-atom? x:&:cell<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> x, <span class="Constant">0/false</span> _, result<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> ] -<span class="muRecipe">def</span> is-pair? x:&:cell<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> is-pair? x:&:cell<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> x, <span class="Constant">0/false</span> @@ -101,8 +101,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> x:&:cell<span class="Special"> <- </span>new-atom s - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-atom? x - <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>is-pair? x + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-atom? x + <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>is-pair? x memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">0</span> @@ -115,18 +115,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> x:&:cell<span class="Special"> <- </span>new-atom s y:&:cell<span class="Special"> <- </span>new-pair x, <span class="Constant">0/nil</span> - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-atom? y - <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>is-pair? y + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-atom? y + <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>is-pair? y memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">1</span> ] ] -<span class="muRecipe">def</span> atom-match? x:&:cell, pat:text<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> atom-match? x:&:cell, pat:text<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - s:text, is-atom?:boolean<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> + s:text, is-atom?:bool<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> <span class="muControl">reply-unless</span> is-atom?, <span class="Constant">0/false</span> result<span class="Special"> <- </span>equal pat, s ] @@ -134,7 +134,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> atom-match [ <span class="Constant">local-scope</span> x:&:cell<span class="Special"> <- </span>new-atom <span class="Constant">[abc]</span> - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>atom-match? x, <span class="Constant">[abc]</span> + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>atom-match? x, <span class="Constant">[abc]</span> memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> ] @@ -143,7 +143,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> first x:&:cell<span class="muRecipe"> -> </span>result:&:cell [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - pair:pair, pair?:boolean<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">pair:variant</span> + pair:pair, pair?:bool<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">pair:variant</span> <span class="muControl">reply-unless</span> pair?, <span class="Constant">0/nil</span> result<span class="Special"> <- </span>get pair, <span class="Constant">first:offset</span> ] @@ -151,7 +151,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> rest x:&:cell<span class="muRecipe"> -> </span>result:&:cell [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - pair:pair, pair?:boolean<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">pair:variant</span> + pair:pair, pair?:bool<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">pair:variant</span> <span class="muControl">reply-unless</span> pair?, <span class="Constant">0/nil</span> result<span class="Special"> <- </span>get pair, <span class="Constant">rest:offset</span> ] @@ -159,7 +159,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> set-first base:&:cell, new-first:&:cell<span class="muRecipe"> -> </span>base:&:cell [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - pair:pair, is-pair?:boolean<span class="Special"> <- </span>maybe-convert *base, <span class="Constant">pair:variant</span> + pair:pair, is-pair?:bool<span class="Special"> <- </span>maybe-convert *base, <span class="Constant">pair:variant</span> <span class="muControl">reply-unless</span> is-pair? pair<span class="Special"> <- </span>put pair, <span class="Constant">first:offset</span>, new-first *base<span class="Special"> <- </span>merge <span class="Constant">1/pair</span>, pair @@ -168,7 +168,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> set-rest base:&:cell, new-rest:&:cell<span class="muRecipe"> -> </span>base:&:cell [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - pair:pair, is-pair?:boolean<span class="Special"> <- </span>maybe-convert *base, <span class="Constant">pair:variant</span> + pair:pair, is-pair?:bool<span class="Special"> <- </span>maybe-convert *base, <span class="Constant">pair:variant</span> <span class="muControl">reply-unless</span> is-pair? pair<span class="Special"> <- </span>put pair, <span class="Constant">rest:offset</span>, new-rest *base<span class="Special"> <- </span>merge <span class="Constant">1/pair</span>, pair @@ -193,7 +193,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color x:&:cell<span class="Special"> <- </span>new-atom s y:&:cell<span class="Special"> <- </span>new-pair x, <span class="Constant">0/nil</span> x2:&:cell<span class="Special"> <- </span>first y - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal x, x2 + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal x, x2 <span class="Constant">11</span>:&:cell/<span class="Special">raw <- </span>rest y memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first is correct</span> @@ -216,15 +216,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> <span class="Comment"># skip whitespace</span> in<span class="Special"> <- </span>skip-whitespace in - c:char, eof?:boolean<span class="Special"> <- </span>peek in + c:char, eof?:bool<span class="Special"> <- </span>peek in <span class="muControl">reply-if</span> eof?, <span class="Constant">0/nil</span> - pair?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">40/open-paren</span> + pair?:bool<span class="Special"> <- </span>equal c, <span class="Constant">40/open-paren</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> pair? <span class="Comment"># atom</span> b:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>end-of-stream? in + done?:bool<span class="Special"> <- </span>end-of-stream? in <span class="muControl">break-if</span> done? <span class="Comment"># stop before close paren or space</span> c:char<span class="Special"> <- </span>peek in @@ -246,11 +246,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color out<span class="Special"> <- </span>new <span class="Constant">cell:type</span> <span class="Comment"># start out with nil</span> <span class="Comment"># read in first element of pair</span> <span class="Delimiter">{</span> - end?:boolean<span class="Special"> <- </span>end-of-stream? in - not-end?:boolean<span class="Special"> <- </span>not end? + end?:bool<span class="Special"> <- </span>end-of-stream? in + not-end?:bool<span class="Special"> <- </span>not end? assert not-end?, <span class="Constant">[unbalanced '(' in expression]</span> c<span class="Special"> <- </span>peek in - close-paren?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">41/close-paren</span> + close-paren?:bool<span class="Special"> <- </span>equal c, <span class="Constant">41/close-paren</span> <span class="muControl">break-if</span> close-paren? first:&:cell, in<span class="Special"> <- </span>parse in *out<span class="Special"> <- </span>merge <span class="Constant">1/pair</span>, first, <span class="Constant">0/nil</span> @@ -259,20 +259,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color curr:&:cell<span class="Special"> <- </span>copy out <span class="Delimiter">{</span> in<span class="Special"> <- </span>skip-whitespace in - end?:boolean<span class="Special"> <- </span>end-of-stream? in - not-end?:boolean<span class="Special"> <- </span>not end? + end?:bool<span class="Special"> <- </span>end-of-stream? in + not-end?:bool<span class="Special"> <- </span>not end? assert not-end?, <span class="Constant">[unbalanced '(' in expression]</span> <span class="Comment"># termination check: ')'</span> c<span class="Special"> <- </span>peek in <span class="Delimiter">{</span> - close-paren?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">41/close-paren</span> + close-paren?:bool<span class="Special"> <- </span>equal c, <span class="Constant">41/close-paren</span> <span class="muControl">break-unless</span> close-paren? read in <span class="Comment"># skip ')'</span> <span class="muControl">break</span> <span class="Constant">+end-pair:label</span> <span class="Delimiter">}</span> <span class="Comment"># still here? read next element of pair</span> next:&:cell, in<span class="Special"> <- </span>parse in - is-dot?:boolean<span class="Special"> <- </span>atom-match? next, <span class="Constant">[.]</span> + is-dot?:bool<span class="Special"> <- </span>atom-match? next, <span class="Constant">[.]</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> is-dot? next-curr:&:cell<span class="Special"> <- </span>new-pair next, <span class="Constant">0/nil</span> @@ -284,7 +284,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># deal with dotted pair</span> in<span class="Special"> <- </span>skip-whitespace in c<span class="Special"> <- </span>peek in - not-close-paren?:boolean<span class="Special"> <- </span>not-equal c, <span class="Constant">41/close-paren</span> + not-close-paren?:bool<span class="Special"> <- </span>not-equal c, <span class="Constant">41/close-paren</span> assert not-close-paren?, <span class="Constant">[')' cannot immediately follow '.']</span> final:&:cell<span class="Special"> <- </span>parse in curr<span class="Special"> <- </span>set-rest curr, final @@ -292,7 +292,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># is going to end the pair</span> in<span class="Special"> <- </span>skip-whitespace in c<span class="Special"> <- </span>peek in - close-paren?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">41/close-paren</span> + close-paren?:bool<span class="Special"> <- </span>equal c, <span class="Constant">41/close-paren</span> assert close-paren?, <span class="Constant">['.' must be followed by exactly one expression before ')']</span> <span class="Delimiter">}</span> <span class="muControl">loop</span> @@ -305,10 +305,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>end-of-stream? in + done?:bool<span class="Special"> <- </span>end-of-stream? in <span class="muControl">reply-if</span> done?, <span class="Constant">0/null</span> c:char<span class="Special"> <- </span>peek in - space?:boolean<span class="Special"> <- </span>space? c + space?:bool<span class="Special"> <- </span>space? c <span class="muControl">break-unless</span> space? read in <span class="Comment"># skip</span> <span class="muControl">loop</span> @@ -334,7 +334,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Comment"># base case: atom</span> <span class="Delimiter">{</span> - s:text, atom?:boolean<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> + s:text, atom?:bool<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> <span class="muControl">break-unless</span> atom? buf<span class="Special"> <- </span>append buf, s <span class="muControl">reply</span> @@ -353,7 +353,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> x:&:cell<span class="Special"> <- </span>parse s - s2:text, <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> <span class="Constant">11</span>:@:char/<span class="Special">raw <- </span>copy *s2 memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is an atom</span> @@ -365,7 +365,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> s:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> x:&:cell<span class="Special"> <- </span>parse s - s2:text, <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> <span class="Constant">11</span>:@:char/<span class="Special">raw <- </span>copy *s2 memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is an atom</span> @@ -380,13 +380,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-should-contain [ app/parse: < abc | < def | <span class="Constant"><></span> > > ] - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x x1:&:cell<span class="Special"> <- </span>first x x2:&:cell<span class="Special"> <- </span>rest x - s1:text, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> - <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>is-pair? x2 + s1:text, <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> + <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>is-pair? x2 x3:&:cell<span class="Special"> <- </span>first x2 - s2:text, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">13</span>:bool/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> <span class="Constant">14</span>:&:cell/<span class="Special">raw <- </span>rest x2 <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 @@ -408,13 +408,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-should-contain [ app/parse: < abc | < def | <span class="Constant"><></span> > > ] - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x x1:&:cell<span class="Special"> <- </span>first x x2:&:cell<span class="Special"> <- </span>rest x - s1:text, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> - <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>is-pair? x2 + s1:text, <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> + <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>is-pair? x2 x3:&:cell<span class="Special"> <- </span>first x2 - s2:text, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">13</span>:bool/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> <span class="Constant">14</span>:&:cell/<span class="Special">raw <- </span>rest x2 <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 @@ -436,17 +436,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-should-contain [ app/parse: < abc | < def | < ghi | <span class="Constant"><></span> > > > ] - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x x1:&:cell<span class="Special"> <- </span>first x x2:&:cell<span class="Special"> <- </span>rest x - s1:text, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> - <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>is-pair? x2 + s1:text, <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> + <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>is-pair? x2 x3:&:cell<span class="Special"> <- </span>first x2 - s2:text, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">13</span>:bool/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> x4:&:cell<span class="Special"> <- </span>rest x2 - <span class="Constant">14</span>:boolean/<span class="Special">raw <- </span>is-pair? x4 + <span class="Constant">14</span>:bool/<span class="Special">raw <- </span>is-pair? x4 x5:&:cell<span class="Special"> <- </span>first x4 - s3:text, <span class="Constant">15</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x5, <span class="Constant">atom:variant</span> + s3:text, <span class="Constant">15</span>:bool/<span class="Special">raw <- </span>maybe-convert *x5, <span class="Constant">atom:variant</span> <span class="Constant">16</span>:&:cell/<span class="Special">raw <- </span>rest x4 <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 @@ -472,11 +472,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-should-contain [ app/parse: < < abc | <span class="Constant"><></span> > | <span class="Constant"><></span> > ] - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x x1:&:cell<span class="Special"> <- </span>first x - <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>is-pair? x + <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>is-pair? x x2:&:cell<span class="Special"> <- </span>first x1 - s1:text, <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> + s1:text, <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> <span class="Constant">13</span>:&:cell/<span class="Special">raw <- </span>rest x1 <span class="Constant">14</span>:&:cell/<span class="Special">raw <- </span>rest x <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 @@ -497,15 +497,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-should-contain [ app/parse: < < abc | <span class="Constant"><></span> > | < def | <span class="Constant"><></span> > > ] - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x x1:&:cell<span class="Special"> <- </span>first x - <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>is-pair? x + <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>is-pair? x x2:&:cell<span class="Special"> <- </span>first x1 - s1:text, <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> + s1:text, <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> <span class="Constant">13</span>:&:cell/<span class="Special">raw <- </span>rest x1 x3:&:cell<span class="Special"> <- </span>rest x x4:&:cell<span class="Special"> <- </span>first x3 - s2:text, <span class="Constant">14</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x4, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">14</span>:bool/<span class="Special">raw <- </span>maybe-convert *x4, <span class="Constant">atom:variant</span> <span class="Constant">15</span>:&:cell/<span class="Special">raw <- </span>rest x3 <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 @@ -552,11 +552,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-should-contain [ app/parse: < abc | def > ] - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x x1:&:cell<span class="Special"> <- </span>first x x2:&:cell<span class="Special"> <- </span>rest x - s1:text, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> - s2:text, <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> + s1:text, <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 memory-should-contain [ @@ -576,15 +576,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-should-contain [ app/parse: < abc | < def | ghi > > ] - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x x1:&:cell<span class="Special"> <- </span>first x x2:&:cell<span class="Special"> <- </span>rest x - s1:text, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> - <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>is-pair? x2 + s1:text, <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> + <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>is-pair? x2 x3:&:cell<span class="Special"> <- </span>first x2 - s2:text, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">13</span>:bool/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> x4:&:cell<span class="Special"> <- </span>rest x2 - s3:text, <span class="Constant">14</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x4, <span class="Constant">atom:variant</span> + s3:text, <span class="Constant">14</span>:bool/<span class="Special">raw <- </span>maybe-convert *x4, <span class="Constant">atom:variant</span> <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 <span class="Constant">40</span>:@:char/<span class="Special">raw <- </span>copy *s3 diff --git a/html/nqueens.mu.html b/html/nqueens.mu.html index 979690cb..c5e06d2d 100644 --- a/html/nqueens.mu.html +++ b/html/nqueens.mu.html @@ -47,7 +47,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if 'queens' is already long enough, print it and return</span> added-so-far:num<span class="Special"> <- </span>length queens <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal added-so-far, n + done?:bool<span class="Special"> <- </span>greater-or-equal added-so-far, n <span class="muControl">break-unless</span> done? stash queens <span class="muControl">return</span> <span class="Constant">1</span> @@ -63,11 +63,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color result<span class="Special"> <- </span>copy <span class="Constant">0</span> next-file:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal next-file, n + done?:bool<span class="Special"> <- </span>greater-or-equal next-file, n <span class="muControl">break-if</span> done? curr:square<span class="Special"> <- </span>merge next-rank, next-file <span class="Delimiter">{</span> - curr-conflicts?:boolean<span class="Special"> <- </span>conflict? curr, queens + curr-conflicts?:bool<span class="Special"> <- </span>conflict? curr, queens <span class="muControl">break-if</span> curr-conflicts? new-queens:&:list:square<span class="Special"> <- </span>push curr, queens sub-result:num<span class="Special"> <- </span>nqueens n, new-queens @@ -78,16 +78,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> conflict? curr:square, queens:&:list:square<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> conflict? curr:square, queens:&:list:square<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result1:boolean<span class="Special"> <- </span>conflicting-file? curr, queens + result1:bool<span class="Special"> <- </span>conflicting-file? curr, queens <span class="muControl">reply-if</span> result1, result1 - result2:boolean<span class="Special"> <- </span>conflicting-diagonal? curr, queens + result2:bool<span class="Special"> <- </span>conflicting-diagonal? curr, queens <span class="muControl">reply</span> result2 ] -<span class="muRecipe">def</span> conflicting-file? curr:square, queens:&:list:square<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> conflicting-file? curr:square, queens:&:list:square<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> curr-file:num<span class="Special"> <- </span>get curr, <span class="Constant">file:offset</span> @@ -95,7 +95,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">break-unless</span> queens q:square<span class="Special"> <- </span>first queens qfile:num<span class="Special"> <- </span>get q, <span class="Constant">file:offset</span> - file-match?:boolean<span class="Special"> <- </span>equal curr-file, qfile + file-match?:bool<span class="Special"> <- </span>equal curr-file, qfile <span class="muControl">reply-if</span> file-match?, <span class="Constant">1/conflict-found</span> queens<span class="Special"> <- </span>rest queens <span class="muControl">loop</span> @@ -103,7 +103,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">reply</span> <span class="Constant">0/no-conflict-found</span> ] -<span class="muRecipe">def</span> conflicting-diagonal? curr:square, queens:&:list:square<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> conflicting-diagonal? curr:square, queens:&:list:square<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> curr-rank:num<span class="Special"> <- </span>get curr, <span class="Constant">rank:offset</span> @@ -117,7 +117,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color file-delta:num<span class="Special"> <- </span>subtract qfile, curr-file rank-delta<span class="Special"> <- </span>abs rank-delta file-delta<span class="Special"> <- </span>abs file-delta - diagonal-match?:boolean<span class="Special"> <- </span>equal rank-delta, file-delta + diagonal-match?:bool<span class="Special"> <- </span>equal rank-delta, file-delta <span class="muControl">reply-if</span> diagonal-match?, <span class="Constant">1/conflict-found</span> queens<span class="Special"> <- </span>rest queens <span class="muControl">loop</span> diff --git a/html/real-files.mu.html b/html/real-files.mu.html index c65a88a5..2ffe5dfc 100644 --- a/html/real-files.mu.html +++ b/html/real-files.mu.html @@ -37,7 +37,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> f:num/file<span class="Special"> <- </span>$open-file-for-reading <span class="Constant">[/tmp/mu-x]</span> $print <span class="Constant">[file to read from: ]</span>, f, <span class="Constant">10/newline</span> - c:char, eof?:boolean<span class="Special"> <- </span>$read-from-file f + c:char, eof?:bool<span class="Special"> <- </span>$read-from-file f $print <span class="Constant">[copying ]</span>, c, <span class="Constant">10/newline</span> f<span class="Special"> <- </span>$close-file f $print <span class="Constant">[file after closing: ]</span>, f, <span class="Constant">10/newline</span> diff --git a/html/tangle.mu.html b/html/tangle.mu.html index 86d824dc..039eacf4 100644 --- a/html/tangle.mu.html +++ b/html/tangle.mu.html @@ -49,7 +49,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><base-case></span> [ <span class="Comment"># if n=0 return 1</span> - zero?:boolean<span class="Special"> <- </span>equal n, <span class="Constant">0</span> + zero?:bool<span class="Special"> <- </span>equal n, <span class="Constant">0</span> <span class="muControl">break-unless</span> zero? <span class="muControl">return</span> <span class="Constant">1</span> ] |