2021-01-21 13:40:28 +01:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
|
|
|
<title>.</title>
|
|
|
|
<style type="text/css">
|
|
|
|
|
|
|
|
* { color: #000; background: #fff; max-width: 700px; }
|
|
|
|
tt, pre { background: #dedede; color: #111; font-family: monospace;
|
|
|
|
white-space: pre; display: block; width: 100%; }
|
|
|
|
.indentedcode { margin-left: 2em; margin-right: 2em; }
|
|
|
|
.codeblock {
|
|
|
|
background: #dedede; color: #111; font-family: monospace;
|
|
|
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
|
|
|
|
padding: 7px;
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.indentedlist { margin-left: 2em; color: #000; }
|
|
|
|
|
|
|
|
span { white-space: pre; }
|
|
|
|
.text { color: #000; white-space: pre; background: #dedede; }
|
|
|
|
.colon { color: #000; background: #dedede; }
|
|
|
|
.note { color: #000; background: #dedede; }
|
|
|
|
.str { color: #000; text-decoration: underline; background: #dedede; }
|
|
|
|
.num { color: #000; background: #dedede; font-weight: bold; font-style: italic; }
|
|
|
|
.fnum { color: #000; font-weight: bold; background: #dedede; }
|
|
|
|
.ptr { color: #000; font-weight: bold; background: #dedede; }
|
|
|
|
.fetch { color: #000; font-style: italic; background: #dedede; }
|
|
|
|
.store { color: #000; font-style: italic; background: #dedede; }
|
|
|
|
.char { color: #000; background: #dedede; }
|
|
|
|
.inst { color: #000; background: #dedede; }
|
|
|
|
.defer { color: #000; background: #dedede; }
|
|
|
|
.imm { color: #000; font-weight: bold; background: #dedede; }
|
|
|
|
.prim { color: #000; font-weight: bolder; background: #dedede; }
|
|
|
|
|
|
|
|
.tt { white-space: pre; font-family: monospace; background: #dedede; }
|
|
|
|
|
|
|
|
.h1, .h2, .h3, .h4 { white-space: normal; }
|
|
|
|
.h1 { font-size: 125%; }
|
|
|
|
.h2 { font-size: 120%; }
|
|
|
|
.h3 { font-size: 115%; }
|
|
|
|
.h4 { font-size: 110%; }
|
|
|
|
.hr { display: block; height: 2px; background: #000000; }
|
|
|
|
</style>
|
|
|
|
</head><body>
|
2022-06-03 12:41:52 +02:00
|
|
|
<p><br/><br/>
|
2021-05-17 19:04:42 +02:00
|
|
|
A big change in Retro 12 was the elimination of the traditional
|
2021-01-21 13:40:28 +01:00
|
|
|
parser from the language. This was a sacrifice due to the lack
|
2021-05-17 19:04:42 +02:00
|
|
|
of an I/O model. Retro has no way to know <strong>how</strong> input is given
|
2021-01-21 13:40:28 +01:00
|
|
|
to the <span class="tt">interpret</span> word, or whether anything else will ever be
|
|
|
|
passed into it.
|
|
|
|
<br/><br/>
|
|
|
|
And so <span class="tt">interpret</span> operates only on the current token. The core
|
|
|
|
language does not track what came before or attempt to guess at
|
|
|
|
what might come in the future.
|
|
|
|
<br/><br/>
|
2021-05-17 19:04:42 +02:00
|
|
|
This leads into the sigils. Retro 11 had a complicated system
|
2021-03-30 13:58:25 +02:00
|
|
|
for sigils, with different types of sigilss for words that
|
2021-01-21 13:40:28 +01:00
|
|
|
parsed ahead (e.g., strings) and words that operated on the
|
2021-05-17 19:04:42 +02:00
|
|
|
current token (e.g., <span class="tt">@</span>). Retro 12 eliminates all of these in
|
2021-03-30 13:58:25 +02:00
|
|
|
favor of just having a single sigil model.
|
2021-01-21 13:40:28 +01:00
|
|
|
<br/><br/>
|
|
|
|
The first thing <span class="tt">interpret</span> does is look to see if the first
|
2021-03-30 13:58:25 +02:00
|
|
|
character in a token matches a <span class="tt">sigil:</span> word. If it does, it
|
|
|
|
passes the rest of the token as a string pointer to the sigil
|
|
|
|
specific handler to deal with. If there is no valid sigil
|
2021-01-21 13:40:28 +01:00
|
|
|
found, it tries to find it in the dictionary. Assuming that it
|
|
|
|
finds the words, it passes the <span class="tt">d:xt</span> field to the handler that
|
|
|
|
<span class="tt">d:class</span> points to. Otherwise it calls <span class="tt">err:notfound</span>.
|
|
|
|
<br/><br/>
|
|
|
|
This has an important implication: <strong>words can not reliably
|
2021-03-30 13:58:25 +02:00
|
|
|
have names that start with a sigil character.</strong>
|
2021-01-21 13:40:28 +01:00
|
|
|
<br/><br/>
|
|
|
|
It also simplifies things. Anything that would normally parse
|
2021-03-30 13:58:25 +02:00
|
|
|
becomes a sigil handler. So creating a new word? Use the <span class="tt">:</span>
|
|
|
|
sigil. Strings? Use <span class="tt">'</span>. Pointers? Try <span class="tt">&</span>. And so on. E.g.,
|
2021-01-21 13:40:28 +01:00
|
|
|
<br/><br/>
|
2021-05-17 19:04:42 +02:00
|
|
|
<tt class='indentedcode'>In ANS | In Retro</tt>
|
2021-01-21 13:40:28 +01:00
|
|
|
<tt class='indentedcode'>: foo ... ; | :foo ... ;</tt>
|
|
|
|
<tt class='indentedcode'>' foo | &foo</tt>
|
|
|
|
<tt class='indentedcode'>: bar ... ['] foo ; | :bar ... &foo ;</tt>
|
|
|
|
<tt class='indentedcode'>s" hello world!" | 'hello_world!</tt>
|
|
|
|
<br/><br/>
|
2021-03-30 13:58:25 +02:00
|
|
|
If you are familiar with ColorForth, sigils are a similar
|
2021-01-21 13:40:28 +01:00
|
|
|
idea to colors, but can be defined by the user as normal words.
|
|
|
|
<br/><br/>
|
|
|
|
After doing this for quite a while I rather like it. I can see
|
|
|
|
why Chuck Moore eventually went towards ColorForth as using
|
2021-03-30 13:58:25 +02:00
|
|
|
color (or sigils in my case) does simplify the implementation
|
2021-01-21 13:40:28 +01:00
|
|
|
in many ways.
|
|
|
|
</p>
|
|
|
|
</body></html>
|