<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Rebol]]></title><description><![CDATA[Rebol]]></description><link>https://rebolcode.com</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 16:37:06 GMT</lastBuildDate><atom:link href="https://rebolcode.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[A Language with context]]></title><description><![CDATA[Have you ever heard about Rebol?
It is programming language born nearly 30 years ago and it is the invention of a genius: Carl Sassenrath, the author of the Amiga multitasking microkernel.
Now it has reached release 3 and it is mantained by Oldes in ...]]></description><link>https://rebolcode.com/a-language-with-context</link><guid isPermaLink="true">https://rebolcode.com/a-language-with-context</guid><dc:creator><![CDATA[Giuseppe Chillemi]]></dc:creator><pubDate>Mon, 02 Jun 2025 23:02:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753125493640/0372a5fb-e0b9-434f-961a-c756dbdff4ec.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Have you ever heard about <a target="_blank" href="https://www.rebol.com/">Rebol</a>?</p>
<p>It is programming language born nearly 30 years ago and it is the invention of a genius: Carl Sassenrath, the author of the Amiga multitasking microkernel.</p>
<p>Now it has reached release 3 and it is mantained by Oldes in his <a target="_blank" href="https://github.com/Oldes/Rebol3">R3 Fork</a></p>
<p>Why is Rebol so special? Because it mimics the our way of using words.</p>
<h2 id="heading-the-human-way">The human way</h2>
<p>Humans are interpreters of the language and they understaning it and its words (symbols), giving them a meaning depening on the context. A word may have different meaning if the context is different. Take as an example the word PLAY, we don’t use it in the same way everywere but its meaning is inferred from the context it is used.</p>
<h2 id="heading-what-is-a-context">What is a context?</h2>
<p>If someone starts talking about an instrument, an auditorium and then about a musician, when you hear to word PLAY, you think about him playing a song; if someone starts talking about a football team, a stadium and a competition, a team will PLAY a game for their amusement and the spectators one.</p>
<p>So, depending on the context built in your mind by the flow of words, PLAY has a different meaning.</p>
<p>It can be a <strong>verb</strong></p>
<ul>
<li><p><strong>To engage in recreational activities:</strong> This includes playing games, sports, or other forms of amusement.</p>
</li>
<li><p><strong>To act, deal, or touch carelessly:</strong> This definition implies a light, speculative, or sportive manner.</p>
</li>
<li><p><strong>To perform on a musical instrument:</strong> This refers to producing music with an instrument.</p>
</li>
<li><p><strong>To act or perform in a play:</strong> This refers to acting a part or role in a dramatic performance.</p>
</li>
<li><p><strong>To give out sounds, especially musical sounds:</strong> This definition focuses on the sound aspect of playing an instrument.</p>
</li>
</ul>
<p>It can be a <strong>noun</strong></p>
<ul>
<li><p><strong>A dramatic performance:</strong> This refers to a play performed on stage or in a theater.</p>
</li>
<li><p><strong>A written work:</strong> This refers to the script of a play, including dialogue and story.</p>
</li>
<li><p><strong>A game or other recreational activity:</strong> This refers to the activity of engaging in a game or other form of amusement.</p>
</li>
<li><p><strong>A skill or trick:</strong> This definition refers to a deliberate coordinated movement requiring dexterity and skill.</p>
</li>
<li><p><strong>The time during which a game proceeds:</strong> This refers to the duration of a game or performance.</p>
</li>
<li><p><strong>Verbal wit or mockery:</strong> This definition refers to a pun or other form of playful mockery</p>
</li>
</ul>
<p><em>A context can be inferred by the use of the words and a word has meaning in a contex.</em></p>
<h2 id="heading-rebol-and-contexts">Rebol and contexts</h2>
<p>While all the other languages usually had some kind of scope for their words, Rebol implements contexts: vocabulary of words specialized in certain areas. So if you are creating a program to play a song and also to show the text of a dialogue, Rebol is able to maintain 2 meanings to the word PLAY. In one context, you define a function that starts the audio playback of a song; in another context the word PLAY is a container with a dialogue.</p>
<p>Is this difficult to implement? No, it is very simple!</p>
<pre><code class="lang-plaintext">ctx1: context [
    play: function [song-number][...code-here...]
    Performers: "Pink Floyd"
]

ctx2: context [
    play: {
        This is a drama written 18th century.
        The story if a princess....
    }
    performer: "The Actors of Hollywood"
    Roles: [
        MAIN-CHARACTER "Jennifer"
        SECONDARY "Romeo"
        OTHERS [
            "Michael"
            "Lucy"
            "Andrea"
    ]
    imdb: "0120384301"
]
</code></pre>
<p>A context may contain infinite words or zero.</p>
<h2 id="heading-a-vocabulary">A Vocabulary</h2>
<p>As written, basically <strong>a context is a vocabulary</strong>. In Rebol you may have as many vocabularies as you want. Your script starts always with the Rebol default one. While you code perform actions, you can create anothe vocabulary where words have different meaning and do or contain different things. They are specialized into a different task and form a different context.</p>
<p>Lets focus on creating a vocabulary to work with songs:</p>
<pre><code class="lang-plaintext">ctx-audio: context [
    play: function [song-number] [...code-here...]
    get-title: func [song-number] [...code-here...]
    current-song: 2
    album-title: "The Dark Side of the Mood"
    artist: "Pink Floyd"
    tracks: [
        "Speak to Me"
        "Breathe (In the Air)"
        "On the Run"
        "Time"
        "The Great Gig in the Sky"
        "Money"
        "Us and Them"
        "AnyColour You Like"
        "Brain Damage"
        "Eclipse"
    ]
]
</code></pre>
<p>As you can see, the vocabulary forming this contexts, has words meaningful for the task of playing the songs of a musical album</p>
<p>For example, if we want to get the tittle of the song 3 and print it on screen, using this vocabulary you can write as follows:</p>
<pre><code class="lang-plaintext">print get-title 3
</code></pre>
<p>How we tell Rebol to use this context for this phrase?</p>
<h2 id="heading-binding-phrases-to-a-vocabulary"><em>Binding phrases to a vocabulary</em></h2>
<p>Each Rebol program is a block with words and other datatypes like numbers</p>
<p>So you express the above code as:</p>
<pre><code class="lang-plaintext">[print get-title 3]
</code></pre>
<p>Now you need to instruct Rebol to use the words in the <code>ctx-audio vocabulary</code></p>
<p>To connect the words of a block to a specific vocabulary so they are searched there, you use the word <code>bind</code>, it contains the code that performs the connection we need.</p>
<pre><code class="lang-plaintext">[bind [print get-title 3] ctx-audio]
</code></pre>
<p>Using <code>bind</code>, all the words of the block will be connected to the ones in <code>ctx-audio</code> context if defined there.</p>
<p>At the end of the connection process, <code>bind</code> returns the code block <code>[print get-title 3]</code></p>
<p><code>bind</code> is defined in the default Rebol vocabulary and available at start.</p>
<h2 id="heading-running-the-code">Running the code</h2>
<p>Now we can run the code as follow:</p>
<pre><code class="lang-plaintext">[do bind [print get-title 3] ctx-audio]
</code></pre>
<p><code>do</code> is another word available in the default vocabulary and it executes the code following it.</p>
<p>Note: it does not execute <code>bind</code> but the result of it, which is:</p>
<pre><code class="lang-plaintext">[print get-title 3]
</code></pre>
<p>The final code that will run is</p>
<pre><code class="lang-plaintext">[do [print get-title 3]]
</code></pre>
<h1 id="heading-final-words">Final words</h1>
<p>We have written that <code>ctx-audio</code> is the vocabulary of words specialized into managing audio content.</p>
<p>The vocabulary and the context refers to the same Rebol element but they are not equivalent. A context is something more, it is a reflection of the vocabulary in your mind and the knowledge about the elements and the dynamic you have about something.<br />In my articles I will talk about context and vocabularies in a mutually exclusive way.</p>
]]></content:encoded></item></channel></rss>