<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Sacred Lake Systems</title>
    <description>Sacred Lake Systems - game development</description>
    <link>https://wwww.sacredlake.systems/</link>
    <atom:link href="https://wwww.sacredlake.systems/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Wed, 11 Nov 2026 20:13:46 +0200</pubDate>
    <lastBuildDate>Wed, 11 Nov 2026 20:13:46 +0200</lastBuildDate>
    <generator>Jekyll v4.4.1</generator>
    
      <item>
        <title>RPG studies: Streets of Rogue</title>
        <description>&lt;p&gt;Welcome to the first entry in a new series, called RPG studies.
In this series, I will go through some roleplaying games
that I think are useful and inspiring for game designers to analyze.&lt;/p&gt;

&lt;p&gt;I will mostly be talking about more niche RPGs, both because
people are less likely to know about them and because they
often take interesting risks.
The featured games will also sometimes stretch the definition of
an RPG, all the better to get influence from the periphery or even
outside of genre boundaries.&lt;/p&gt;

&lt;p&gt;So I will mostly be ignoring games by Bethesda, Bioware, 
Larian, CD Projekt Red, et al. 
Those are assumed to be common knowledge.&lt;/p&gt;

&lt;p&gt;All right, without further ado, let’s get into our first game.&lt;/p&gt;

&lt;h1 id=&quot;streets-of-rogue&quot;&gt;Streets of Rogue&lt;/h1&gt;

&lt;p&gt;&lt;img src=&quot;/images/streets-of-rogue/01.jpg&quot; alt=&quot;Streets of Rogue title screen&quot; /&gt;
&lt;em&gt;Streets of Rogue title screen&lt;sup id=&quot;fnref:1&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://streetsofrogue.com/&quot;&gt;Streets of Rogue&lt;/a&gt; is often 
described as “Deus Ex meets GTA”
and as the name suggests, is a (non-traditional) roguelike&lt;sup id=&quot;fnref:2&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.
The game has you go through six stages of a city  on your quest to
liberate it from the clutches of a corrupt mayor.&lt;/p&gt;

&lt;p&gt;If you are not already familiar with it, the trailer provides a good
overview of the game:&lt;/p&gt;

&lt;div class=&quot;videoWrapper&quot;&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/Whqzf1d-E2w &quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;

&lt;h1 id=&quot;lessons&quot;&gt;Lessons&lt;/h1&gt;
&lt;p&gt;Here I’ll list features and aspects of the game that I think
are useful for a game designer to study.&lt;/p&gt;

&lt;h2 id=&quot;character-integration&quot;&gt;Character integration&lt;/h2&gt;
&lt;p&gt;In Streets of Rogue, both you and the Non-Player Characters (NPCs)
use the same pool of character classes. This is a classic roguelike
pattern now used in other genres as well.&lt;/p&gt;

&lt;p&gt;Because a roguelike is typically a very simulation-heavy genre,
it pays dividends to have the “monsters” and the player share the same 
code. This is something Nethack famously did NOT do and are still paying
the price for.&lt;/p&gt;

&lt;p&gt;In Streets of Rogue the practical consequence of this is that the
player can play as (almost) any NPC role in the game.
Want to be a zombie? Sure. A bartender? Yes.&lt;/p&gt;

&lt;p&gt;There are some differences. For example, a player playing as a 
shopkeeper does not literally run a shop in the game like the NPCs do.
But mostly the same systems are used by the player and NPCs.&lt;/p&gt;

&lt;p&gt;This includes things like allegiances, 
where members of the same gang defend each other
when attacked, both NPC and player thieves pickpocket passersby and
vampires heal by sucking the blood out of their victims.&lt;/p&gt;

&lt;p&gt;Which leads us to our next point.&lt;/p&gt;

&lt;h2 id=&quot;character-variety&quot;&gt;Character variety&lt;/h2&gt;
&lt;p&gt;Compared to your standard RPG, Streets of Rogue has an incredible list
of character options that actually play differently.&lt;/p&gt;

&lt;p&gt;For example, play as a cop and:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Other cops will defend you if you are attacked&lt;/li&gt;
  &lt;li&gt;You can handcuff any NPC, incapacitating them&lt;/li&gt;
  &lt;li&gt;You lose experience if you arrest or kill innocent people&lt;sup id=&quot;fnref:3&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
  &lt;li&gt;You can enter and exit police stations at will&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the other hand, playing as a gorilla, you can’t talk to people
or use guns at all and scientists attack you on sight. A bartender
can turn any chemical into a servable drink. Et cetera, et cetera.&lt;/p&gt;

&lt;p&gt;Note that roles like the bartender would not be possible
if most of the NPCs were not neutral or if there was a strict
separation between non-combat NPCs (townies) and combat NPCs (monsters).
A lot of the local variety is driven by which NPCs you have befriended
and offended on the current level.&lt;/p&gt;

&lt;p&gt;Another big part of why this variety is possible is that like most
traditional roguelikes and unlike most RPGs, there are is no
separate tactical combat minigame that every character must 
take part in.&lt;/p&gt;

&lt;h2 id=&quot;no-combat-or-dialogue-minigames&quot;&gt;No combat or dialogue minigames&lt;/h2&gt;
&lt;p&gt;Everything in Streets of Rogue happens in the same game mode,
not including out-of-gameplay activities like level up screens.&lt;/p&gt;

&lt;p&gt;Talking, fighting and sneaking around all take place in the 
same mode and can therefore be transitioned into and out of fast
and smooth.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/streets-of-rogue/02.jpg&quot; alt=&quot;Streets of Rogue interaction menu&quot; /&gt;
&lt;em&gt;This menu might sometimes 
look like a dialogue minigame. 
But it’s always simply a menu for choosing an action.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This may seem trivial but think about all the times you couldn’t
cast spells in the middle of dialogue because
the writer didn’t add an option to do it&lt;sup id=&quot;fnref:4&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;. Or when you snuck
up on an enemy, only to be whisked away to a scripted fight
where they attack first.&lt;/p&gt;

&lt;p&gt;In Streets of Rogue, this comes down to organically 
choosing how to approach each objective and adapting that plan
on the fly. Usually by starting with stealth or diplomacy and
ending with a fight and/or running away.&lt;/p&gt;

&lt;h2 id=&quot;lowest-common-denominator&quot;&gt;Lowest common denominator&lt;/h2&gt;
&lt;p&gt;This leads us to the weakest part of Streets of Rogue. To be fair,
I am not sure if there is a solution to this problem.&lt;/p&gt;

&lt;p&gt;See, the player has to be able to accomplish each mission regardless
of their current state. There should never be a situation where
the player has effectively lost but the game is not over yet.&lt;/p&gt;

&lt;p&gt;Therefore, three things are always available to the player.
The player can always 1) walk to an objective, 2) interact with it 
and 3) neutralize it if it is the goal of the mission.&lt;/p&gt;

&lt;p&gt;In practice this means that even a character with the pacifist trait
like the doctor, can still punch people.
It also means that bypassing the entertaining systems and punching
your way through is always a viable path.&lt;/p&gt;

&lt;p&gt;This is smart from a UX perspective but does mean that nothing
 prevents players from gravitating towards
the easiest available strategy instead of engaging with the
variety of systems on offer.&lt;/p&gt;

&lt;h2 id=&quot;explicit-objectives&quot;&gt;Explicit objectives&lt;/h2&gt;
&lt;p&gt;But on the more positive side are those objectives themselves.
There’s a decent amount of variety of objectives and approaches.
But what I want to focus here is the clarity of the mission
information.&lt;/p&gt;

&lt;p&gt;On each level, you have to complete several missions to be allowed
to leave the level. The location and nature of these is immediately
available in your map screen, and you usually check these
as soon as you enter a level&lt;sup id=&quot;fnref:5&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;Now quest markers have a bad reputation for a good reason.
And this wouldn’t work for every game, especially any game
where exploring the environment is the point.&lt;/p&gt;

&lt;p&gt;But here I think it works for two reasons.&lt;/p&gt;

&lt;p&gt;First, there is no environmental
storytelling to absorb. The levels are procedurally generated
and meant to be progressed through at a brisk pace. There is also
no pretense of the player investigating a mystery or searching
for secrets. The narrative is that each mission is a briefing
from the HQ.&lt;/p&gt;

&lt;p&gt;Second, the levels are 2D and fairly small. 
This means that often it’s enough to look at the map to get
a general idea of the direction the objective’s in. 
The challenge is not in finding the objective and completing
the objective is never as straightforward as walking up to it 
and pressing E.&lt;/p&gt;

&lt;p&gt;Often you are making a plan based on the objective’s location,
surrounding patrols, 
your abilities and other threats and opportunities. 
Which is also something that is uncommon in RPGs, at least outside
of combat encounters.&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;There’s a lot more to say about Streets of Rogue that I didn’t cover
here. If you would like to know more, play the game yourself or
check out &lt;a href=&quot;https://www.youtube.com/watch?v=Zh050k7B7Ns&quot;&gt;this video&lt;/a&gt;
from Lychee Game Labs.&lt;/p&gt;

&lt;p&gt;That’s it for the first installment of RPG studies.
Hope you have a great day and I will see you next time.&lt;/p&gt;

&lt;p&gt;P.S. I am still figuring out Jekyll. You can see I found out how to
make footnotes and embed images and videos. I still wanna overhaul
the site at some point though.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot;&gt;
      &lt;p&gt;All screenshots via &lt;a href=&quot;https://www.mobygames.com/&quot;&gt;MobyGames&lt;/a&gt; &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot;&gt;
      &lt;p&gt;I know some people still call these “roguelites” but I think
that ship has sailed years and years ago. I know, I know. I used to harp on
about this as well. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot;&gt;
      &lt;p&gt;The other cops won’t stop you and sometimes the cost is worth it.
Just like a real police officer. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot;&gt;
      &lt;p&gt;To be fair, this is almost always an architectural issue, 
not the fault of the writer. Traditional dialogue trees
are really resistant to player verbs. &lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot;&gt;
      &lt;p&gt;There is an interesting parallel with 
the &lt;a href=&quot;https://en.wikipedia.org/wiki/Trophy_RPG&quot;&gt;Trophy RPG&lt;/a&gt;
tabletop roleplaying system, where players are also
explicitly told what their objective is in each scene.
I would like to see this in practice one day. &lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Wed, 11 Nov 2026 00:00:00 +0200</pubDate>
        <link>https://wwww.sacredlake.systems/rpg-studies-sor</link>
        <guid isPermaLink="true">https://wwww.sacredlake.systems/rpg-studies-sor</guid>
        
        <category>RPG studies</category>
        
        <category>Design</category>
        
        
      </item>
    
      <item>
        <title>Sacred Lake AI policy</title>
        <description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;I guess it’s time to talk about generative AI lest people think I am 
some sort of time traveler from the 2010s and have simply not
heard the news about our lord and saviour 
&lt;em&gt;[insert this month’s AI product here]&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;But since it is a heavy subject, let me lighten the mood
and start with a joke.
This was said by my former coworker. I don’t know if they meant it
as a joke, but it did register as one to me. What they said was something like:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;You vegetarian for ethical, political,
environmental, personal or health
reasons?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And here’s another joke for you:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Are you against using AI in games?&lt;/p&gt;

  &lt;p&gt;Of course not, I love GOAP!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Okay, now that the fun part is over, time to talk about AI.&lt;/p&gt;

&lt;h1 id=&quot;asset-generation&quot;&gt;Asset generation&lt;/h1&gt;
&lt;p&gt;I will not use generative AI to create images, sounds, text or any
other asset for my games. Any asset packs I use will also be
free of AI, although that will probably get harder and harder
to perfectly enforce since a lot of people have an incentive to
lie about their use of AI.&lt;/p&gt;

&lt;p&gt;I don’t think people really need an explanation for this one.
But in case you yourself are a time traveler from the 2010s,
there’s the built-in plagiarism, the legal risks, 
the shallow quality, and lack of control to name a few.&lt;/p&gt;

&lt;h2 id=&quot;disclaimer&quot;&gt;Disclaimer&lt;/h2&gt;
&lt;p&gt;This is about me and my games. I do not care if you use AI or not.
I will avoid your products if you do, however.
At least if you use it for asset generation. Code is a bit more
complicated.&lt;/p&gt;

&lt;h1 id=&quot;code-generation&quot;&gt;Code generation&lt;/h1&gt;
&lt;p&gt;I’ve split this into a separate category since this is 
more controversial and I have used LLMs like Opus to generate
code professionally
before. And I am willing to use them again for other people
if I one day return to a software engineering day job.&lt;/p&gt;

&lt;p&gt;But I will not be using code generation tools for my own projects.&lt;/p&gt;

&lt;h2 id=&quot;the-joy-of-clojure&quot;&gt;The Joy of Clojure&lt;/h2&gt;
&lt;p&gt;The primary reason is that I like programming. I like thinking
about systems and implementing them. 
I like refactoring a lot. 
I even enjoy debugging, sometimes.&lt;/p&gt;

&lt;p&gt;If I didn’t like
coding, I would just use an engine like Godot and be done with it.
Most of game development is not actually coding. Unless you’re making
some really cutting edge physics or simulation I guess.&lt;/p&gt;

&lt;p&gt;Now I know that being able to choose your tools is a privileged
position. If you are a software engineer whose full time
job it is now to either read AI output or prompt it my heart goes
out to you. And if you are support staff in a company whose engineers
decided to stop reading the code my heart goes out to you too.&lt;/p&gt;

&lt;p&gt;I do wish you would stop structuring your day to optimize your token 
window reset.&lt;/p&gt;

&lt;h2 id=&quot;cottagecore&quot;&gt;Cottagecore&lt;/h2&gt;
&lt;p&gt;The secondary reason is that I don’t really need the tools for
this type of project, anyway. Programming output won’t really 
be the bottleneck here and the codebase is so small
I can pretty much remember all of it.&lt;/p&gt;

&lt;p&gt;There’s no tedious integrations or other
boilerplate to generate either.&lt;/p&gt;

&lt;p&gt;It’s simply not worth the potential efficiency gains to
juggle token allowances, 
worry about leaks, maintain the harness 
and pay for subscription tokens for a one-man operation.&lt;/p&gt;

&lt;p&gt;You may counter that I will be left behind, 
that no-one will buy my games.
But that’s always been the risk. The vast majority of games
do not make any profit.&lt;/p&gt;

&lt;p&gt;If it doesn’t work out it doesn’t work out.&lt;/p&gt;

&lt;p&gt;Some people also don’t make distinctions between asset and code
generation and oppose all use of generative AI in games. 
Which I believe is a valid position, although I am not sure
how much I agree.&lt;/p&gt;

&lt;h2 id=&quot;ozymandias&quot;&gt;Ozymandias&lt;/h2&gt;
&lt;p&gt;The tertiary reason is that I am not sure the tech can sustain
dedicated game development. It’s already over a month since the
latest model that was supposed to upend everything, Opus 5.5,
was released and all we’ve seen so far is, pardon my English,
demo porn and clones of small games.&lt;/p&gt;

&lt;p&gt;If AI is so capable, why aren’t there more examples of good games
made with it by now? I know it’s not a lack of effort or tokens.
Or time. I’ve played some game jam games made in a week 
without AI that are more exciting and fun.&lt;/p&gt;

&lt;p&gt;And why is it that now that people supposedly have the power
to make whatever they want, they are now just remaking the 
same things that already exist?&lt;/p&gt;

&lt;p&gt;Of course, some of this is subjective.
Maybe you really like Vampire Survivors clone #543 but with
AI generated graphics?&lt;/p&gt;

&lt;p&gt;But for myself, I haven’t seen it handle a long-term
project I would care about, let alone care about making. 
Meanwhile, human-made games, even
solo-developed ones, are everywhere and everywhen.&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;More fun topics next time.
I wanted to keep this on topic and relatively brief, so I didn’t
touch on the doomerism and utopianism in the world today.&lt;/p&gt;

&lt;p&gt;It’s okay to not ride the AI lightning every day.
Remember that all the people who didn’t install Clawdbot
are still here. 
Heck, I’d bet most people have never even heard about it.&lt;/p&gt;

&lt;p&gt;Take care of yourself out there.&lt;/p&gt;

&lt;p&gt;P.S. I think I am going to start linking to a post or video related
to the topic at the end of these, and since I didn’t really talk
about the artistic side,
here’s a post about 
&lt;a href=&quot;https://www.workingtheorys.com/p/make-something-heavy&quot;&gt;making something heavy&lt;/a&gt;.&lt;/p&gt;
</description>
        <pubDate>Wed, 04 Nov 2026 00:00:00 +0200</pubDate>
        <link>https://wwww.sacredlake.systems/ai-policy</link>
        <guid isPermaLink="true">https://wwww.sacredlake.systems/ai-policy</guid>
        
        <category>General</category>
        
        
      </item>
    
      <item>
        <title>Enaml - part 3</title>
        <description>&lt;p&gt;This is the third post about my Domain Specific Language (DSL).
See &lt;a href=&quot;/enaml-part-1&quot;&gt;part 1 here&lt;/a&gt; if you missed it. There’s also 
&lt;a href=&quot;/enaml-part-2&quot;&gt;part 2 here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Last time we went through the basic tags and this time we will
go through the advanced or meta tags.&lt;/p&gt;

&lt;h1 id=&quot;meta-tags&quot;&gt;Meta tags&lt;/h1&gt;
&lt;p&gt;Now we get into the real juicy stuff.
These are more advanced tags that let nodes inherit from other nodes
or otherwise indirectly affect the node. They heavily utilize
the node’s path so if you skipped the key tag section in part 2, 
make sure you read that first.&lt;/p&gt;

&lt;h2 id=&quot;inheritance-tag&quot;&gt;Inheritance tag&lt;/h2&gt;
&lt;p&gt;The inheritance tag copies the contents (including children) of the
given node into this one:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;checkbox&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The tag simply contains the path of the inherited node.
For example, here we specify once the font values for a label:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;font&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;courier&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;font&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Which we can then use in a different context:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;header&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;Menu&quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;font&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;Sandwich&quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;Salmon tofurkey&quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;Coffee&quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note that the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;font-size&lt;/code&gt; attribute overrides the inherited value
so the “Menu” title is bigger. We could also use multiple inheritance
like this if we wanted to make it into a widget of its own:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;font&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is not object-oriented style inheritance; more like the prototype
style inheritance used in some languages but even simpler.
The contents of the source node are simply copied into the current one
at parse time from left to right.&lt;/p&gt;

&lt;p&gt;This reduces the amount of copy-paste an author has to do. It’s an
especially common pattern in traditional roguelike codebases where
there are a lot of variants of a base object (like a basic goblin,
a goblin mage, king, etc.)&lt;/p&gt;

&lt;p&gt;Because the inherited node can be anywhere in the tree, the user is
free to define their own “node template” libraries how they see fit.&lt;/p&gt;

&lt;p&gt;But the true power of inheritance comes when combined with the last two
tags; overwriting and replacement.&lt;/p&gt;

&lt;h2 id=&quot;overwrite-tag&quot;&gt;Overwrite tag&lt;/h2&gt;
&lt;p&gt;The overwrite tag tells the parses how to handle existing data
when we are defining a node on top of an already existing one.
It is a series of flags after the tag prefix semicolon:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;If you recall the key tag definition above, in Enaml you can
define a node anywhere in the file you want, even multiple times.
Imagine a situation where a mod wants to add location data
to existing entities:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ontario&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Lake Ontario&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;algae&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Algae Lake&quot;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;# ...other data...
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ontario&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;canada&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;algae&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;antarctica&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This works but produces a warning because Enaml doesn’t know
if the user added the data intentionally or not.
Adding the overwrite tag removes the warning:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ontario&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;canada&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;algae&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;antarctica&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note that the tag is empty since we are not doing anything special.&lt;/p&gt;

&lt;h3 id=&quot;overwrite-flags&quot;&gt;Overwrite flags&lt;/h3&gt;
&lt;p&gt;The default behavior for overwriting is to:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;replace the original text with the new text, if any&lt;/li&gt;
  &lt;li&gt;add any new basic tags to the list of original tags&lt;/li&gt;
  &lt;li&gt;keep the child nodes as-is&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the user wants to do something special, these are the flags they
can give:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt; to append the text instead of replacing it&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p&lt;/code&gt; to prepend the text instead of replacing it&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t&lt;/code&gt; to remove original basic tags&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;c&lt;/code&gt; to remove original child nodes&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d&lt;/code&gt; to delete the original node itself&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not all combinations of flags are valid, obviously.
The delete flag especially makes the other flags meaningless.&lt;/p&gt;

&lt;h3 id=&quot;multiline-nodes&quot;&gt;Multiline nodes&lt;/h3&gt;
&lt;p&gt;Some of you may have noticed last time is that if every line
is a node and tags, how the heck do multiline strings work? Or
a particularly long list of tags?&lt;/p&gt;

&lt;p&gt;Well, first of all I did deliberately choose the single line format
default because I want to guide myself away both from complicating
things and from writing walls of text. 
A lot of the philosophy around this project revolves around the
&lt;a href=&quot;https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it&quot;&gt;YAGNI&lt;/a&gt; 
and especially &lt;a href=&quot;https://en.wikipedia.org/wiki/KISS_principle&quot;&gt;KISS&lt;/a&gt;
principles.&lt;/p&gt;

&lt;p&gt;But the reality is that sometimes you really need that ability to
add a linebreak or two. For this the overwrite tag has a special case.&lt;/p&gt;

&lt;p&gt;If you define a node without a key, it usually gets a generated one
automatically. However, if it is at the same indentation as the previous
line, and it has an overwrite tag, it is instead used to overwrite
the previous node. So if you have a wall of text, you can write it
like this (text from Wikipedia):&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;blatherings&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;feature&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;creep&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Feature creep is the &quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;excessive ongoing &quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;expansion or addition of &quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;new features in a product, &quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;especially in computer &quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;software, video games &quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;(where it should not be &quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;confused with power creep) &quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;and consumer and business &quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;electronics.&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The same principle works for tags.&lt;/p&gt;

&lt;p&gt;This has the added benefit of being able to line up the multiline 
strings which is important for readability.&lt;/p&gt;

&lt;h3 id=&quot;localization&quot;&gt;Localization&lt;/h3&gt;
&lt;p&gt;Another thing that might have raised concerns from people
about the previous post is the question of localization.
It is a bad habit in the game dev community to mix code and UI text.
This results in problems down the line.&lt;/p&gt;

&lt;p&gt;I don’t think localization will be that relevant for me
because lots of very dynamic text is notoriously difficult to localize.
English is also particularly good for dynamic text 
(lots and lots of synonyms, regular verbs, non-gendered nouns, etc.)&lt;/p&gt;

&lt;p&gt;But still, it is pretty easy to process your translations into
and out of
a replacement data file which only affects the text fields:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;car&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;auto&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;boat&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;vene&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;animals&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;the&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;kissa&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;animals&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;the&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;koira&quot;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;# ...etc...
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note how the third and fourth rows have a node which did not 
have an explicit key so an implicit one was generated for them and
therefore they can still be overwritten here.&lt;/p&gt;

&lt;p&gt;Extracting the above file should also be easy to add if the need
arises since I already have a parser that turns Enaml into EDN.
Some translation file formats can also contain hints to the context
of the translation. The system could also use the inherent structure
of the Enaml source files to provide this automatically.&lt;/p&gt;

&lt;h2 id=&quot;replacement-tag&quot;&gt;Replacement tag&lt;/h2&gt;
&lt;p&gt;The replacement tag allows the user to do a find &amp;amp; replace operation
on the current node:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Here we are replacing each &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;X&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;5&lt;/code&gt; and each &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Y&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;6&lt;/code&gt; in the 
current node and its child nodes. Any number of replacements are
accepted, could be just one &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;=X.5&lt;/code&gt; or three &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;=X.5.Y.6.Z.true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I guess you could use it on a single node, but its true power
comes with being combined with the other meta tags.&lt;/p&gt;

&lt;h3 id=&quot;meta-tags-combined&quot;&gt;Meta tags combined&lt;/h3&gt;
&lt;p&gt;You can use inheritance to copy a complex node and then selectively
overwrite its children. Like this:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hard&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;checkbox&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FLAG&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hard&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Hard mode&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Where checkbox is a user-defined widget made of primitive UI components
like images and labels. Inheritance allows us to hide most of
the repetitive stuff in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ui.checkbox&lt;/code&gt; and replacement allows us to
reach into it to change what value the checkbox affects.&lt;/p&gt;

&lt;p&gt;It is almost like defining functions or macros in an actual programming
language.&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;This was pretty technical and I think enough about Enaml for now.&lt;/p&gt;

&lt;p&gt;If you want to read more writing like this, one of my favorites is
the &lt;a href=&quot;https://versu.com/about/how-versu-works/&quot;&gt;documentation for Versu&lt;/a&gt;
and especially the DSL for it called Praxis.
You can probably
see how it has been an inspiration, what with the logic programming
and dot notation.
Although Praxis has a more focused scope.&lt;/p&gt;

&lt;p&gt;Other inspirations are of course YAML and XML. From the Clojure
ecosystem also re-frame with its 
&lt;a href=&quot;https://github.com/day8/re-frame/blob/master/docs/data-oriented-design.md&quot;&gt;data-oriented events and hiccup syntax&lt;/a&gt;.
Maybe more about this when it’s time to write about the event handling.&lt;/p&gt;

&lt;p&gt;But a less technical post for next time so see you then!&lt;/p&gt;
</description>
        <pubDate>Wed, 28 Oct 2026 00:00:00 +0200</pubDate>
        <link>https://wwww.sacredlake.systems/enaml-part-3</link>
        <guid isPermaLink="true">https://wwww.sacredlake.systems/enaml-part-3</guid>
        
        <category>Enaml</category>
        
        <category>Dev</category>
        
        
      </item>
    
      <item>
        <title>Enaml - part 2</title>
        <description>&lt;p&gt;This is the second post about my Domain Specific Language (DSL).
See &lt;a href=&quot;/enaml-part-1&quot;&gt;part 1&lt;/a&gt; if you missed it. 
There’s also &lt;a href=&quot;/enaml-part-3&quot;&gt;part 3&lt;/a&gt; which I separated into a separate
post since this got too long.&lt;/p&gt;

&lt;p&gt;A quick reminder is that an Enaml document is a tree of nodes,
and each node can have text and/or tags.&lt;/p&gt;

&lt;h1 id=&quot;basic-tags&quot;&gt;Basic tags&lt;/h1&gt;
&lt;p&gt;These are the basic tags that structure, name, and populate the nodes.
Later we will look at more advanced meta tags that manipulate 
other nodes or even the parser.&lt;/p&gt;

&lt;h2 id=&quot;key-tag&quot;&gt;Key tag&lt;/h2&gt;
&lt;p&gt;The key tag is used to name the node and uses the colon:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;:entities.lakes.ontario
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This is obviously inspired by keywords, which are often used
to define keys in EDN files.&lt;/p&gt;

&lt;h3 id=&quot;unique-keys-and-ids&quot;&gt;Unique keys and IDs&lt;/h3&gt;
&lt;p&gt;Remember that in Enaml the document is a tree and each node has
a locally unique id (no sibling nodes may have the same key).
This means that if you take the keys at each step from the root to
the node, you get a unique id for the node itself.&lt;/p&gt;

&lt;p&gt;You can see how useful this is if you’ve ever worked with React
and gotten those “key missing” errors because React can’t deduce
which elements were changed. The lake engine 
(I guess I am calling it that now)
also works similarly so having this whole category of issues 
automatically sidestepped is pretty nice.&lt;/p&gt;

&lt;h2 id=&quot;paths&quot;&gt;Paths&lt;/h2&gt;
&lt;p&gt;The way the key tag works under the hood is that it actually defines
a subpath to the node from its parent. So these four examples are
 the same from the parser’s point of view and create the same three
nodes:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ontario&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Lake Ontario&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ontario&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Lake Ontario&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ontario&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Lake Ontario&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ontario&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Lake Ontario&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;As you can see, this helps an author reduce the space
needed even with linebreaks and indentation mattering in Enaml.
It is also useful for modding since the modder can just add
children to an existing node without modifying the original file.&lt;/p&gt;

&lt;p&gt;This relates to the second useful thing about the key tag,
which is that the path it defines
can be used for inheritance or overwriting tags.
More about these in the meta tag section below.&lt;/p&gt;

&lt;h3 id=&quot;data-grouping&quot;&gt;Data grouping&lt;/h3&gt;
&lt;p&gt;The third useful thing about the key tag is that it allows an author
to group the data however they want. You can either group data by
type (GUI, events, entities, etc.) or by domain
(main menu, town exploration, combat, etc.).
The end result from the game’s point of view is the same.&lt;/p&gt;

&lt;p&gt;An example is probably needed. These two examples
both result in the same data structure. Here’s the plain structure:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;# All entities
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ontario&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Lake Ontario&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;algae&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Algae Lake&quot;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;# All actions
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actions&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fishing&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;research&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;And here’s the same data grouped by domain:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;# Canada
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ontario&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Lake Ontario&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fishing&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;# Antarctica
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lakes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;algae&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Algae Lake&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;research&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(By the way, look at this &lt;del&gt;photograph&lt;/del&gt;
&lt;a href=&quot;https://en.wikipedia.org/wiki/Melt_pond#/media/File:Ponds_on_the_Ocean,_ICESCAPE.jpg&quot;&gt;melt pond image&lt;/a&gt;
on Wikipedia I came across while looking for a list of lakes. Damn.)&lt;/p&gt;

&lt;p&gt;Obviously the data would need conditions and other things for
the engine to understand the domain divisions but this is
something that would have to be done anyway so I’ve simplified the
example to hopefully make it clearer.&lt;/p&gt;

&lt;p&gt;This also in the same file. In a real use case you would probably
have one file for Antarctica and another for Canada. And separate files
for common stuff shared by both.&lt;/p&gt;

&lt;h2 id=&quot;attribute-tag&quot;&gt;Attribute tag&lt;/h2&gt;
&lt;p&gt;The attribute tag defines the values associated with the node, like
the values for a GUI element:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;align&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;left&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;invite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PLAYER&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Above we have a node with four attributes.
Basically you can think of these as XML attributes or EDN hash-map 
key-value pairs.&lt;/p&gt;

&lt;p&gt;Some of the parts of the attribute tag define the path to an attribute
and some (usually the last part) determines the value.&lt;/p&gt;

&lt;p&gt;So here the above values would result in the following Clojure data
structure:&lt;/p&gt;
&lt;div class=&quot;language-clojure highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; other node related stuff&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:align&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:left&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:border&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:width&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:on-click&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:invite&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;&apos;?PLAYER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;on-schema&quot;&gt;On schema&lt;/h3&gt;
&lt;p&gt;But how does the system know when the path ends and the
value begins?&lt;/p&gt;

&lt;p&gt;This is one of the joys of a DSL. I was wracking my brain trying
to figure out how the syntax is supposed handle this problem. 
I was almost resigned to adding some sort of comma based system 
to the notation which would have been pretty horrible to read and write.&lt;/p&gt;

&lt;p&gt;But then I realized that precisely because I am not making a generic 
language, I already know what schema the system is using. 
So the user never even has to
know what the above looks like in the code. They just have to know
where and how to use it.&lt;/p&gt;

&lt;p&gt;This doesn’t just apply to attributes; every tag is simply a prefix
character followed by dot notation alphanumeric, kebab-case words.
Sometimes with syntactic sugar on top.&lt;/p&gt;

&lt;h2 id=&quot;condition-tag&quot;&gt;Condition tag&lt;/h2&gt;
&lt;p&gt;The condition tag starts with a question mark or an exclamation point
and defines a pre-condition for the node:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ITEM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;potion&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Would make the node valid when the variable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ITEM&lt;/code&gt;
was an entity that was a potion. The negation of that condition would
use an exclamation point and be valid if the ITEM was not a potion or
if it didn’t have a type at all:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ITEM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;potion&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The meaning of “valid” here depends on the context,
so a UI widget would only be shown on the screen if it was valid.
An event listener or guard would only trigger if it was valid too.&lt;/p&gt;

&lt;p&gt;One way of looking at it is that a node with an invalid condition
doesn’t exist in the tree at that point. This includes its child nodes.&lt;/p&gt;

&lt;h3 id=&quot;datalog&quot;&gt;Datalog&lt;/h3&gt;
&lt;p&gt;Like I said last time, under the hood the conditions become Datalog
(specifically DataScript) query clauses. 
It’s a pretty natural fit with the dot notation since Datalog
clauses are also mostly a sequence of terms.&lt;/p&gt;

&lt;p&gt;For example, the above condition (the question mark one) becomes:&lt;/p&gt;
&lt;div class=&quot;language-clojure highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;?ITEM&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:type&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:potion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However, there are special forms that allow 
the user to go beyond simple entity-attribute-value comparisons. 
These are necessary because more advanced forms of clauses in Datalog
have some funky nesting and symbol use involved which would be hard
to do justice to with dot notation.&lt;/p&gt;

&lt;p&gt;This is true of the negation first of all.
The above negation would become:&lt;/p&gt;
&lt;div class=&quot;language-clojure highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;not&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;?ITEM&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:type&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:potion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;special-conditions-case&quot;&gt;Special conditions: case&lt;/h3&gt;
&lt;p&gt;The most important of the special conditions is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;case&lt;/code&gt; condition:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IMAGE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MENU&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bg1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bg2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bg3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Which is read as “If we are in the main menu, use background image 1,
if we are in the options menu use background image 2, otherwise use
background image 3.”&lt;/p&gt;

&lt;p&gt;It’s probably easier to understand through its rough Clojure equivalent,
which would be something like:&lt;/p&gt;
&lt;div class=&quot;language-clojure highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IMAGE&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MENU&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
              &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:main&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:bg1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
              &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:options&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:bg2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
              &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:bg3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
     &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Although of course what it is actually turned into is Datalog where
clauses. Behold:&lt;/p&gt;
&lt;div class=&quot;language-clojure highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;or&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; 
   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;and&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;?MENU&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; 
         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ground&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:bg1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;?IMAGE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;and&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;?MENU&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; 
         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ground&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:bg2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;?IMAGE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ground&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:b3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;?IMAGE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Now there are other ways of doing the above (and I haven’t actually 
checked that it works), but I hope you see how having a DSL for these is
useful for shielding the user from the Datalog syntax.&lt;/p&gt;

&lt;p&gt;To be fair to Datalog, this use case is far from normal since we have
to bind the “output” of the condition to a variable to be able
to use it in the rest of the node. If you were making
the queries directly this would not be necessary.&lt;/p&gt;

&lt;p&gt;Also, the fact that Datalog has such a composable structure is 
the reason why this is so easy to build on top of it in the first
place.&lt;/p&gt;

&lt;h3 id=&quot;special-conditions-if&quot;&gt;Special conditions: if&lt;/h3&gt;
&lt;p&gt;Another important special condition is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;if&lt;/code&gt;, which is really just 
a special case of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;case&lt;/code&gt;. 
You can probably figure out how this checkbox logic works based
on the above:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IMAGE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CHECKED&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;empty&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;In addition to the simpler syntax, this also solves another problem:
we can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;else&lt;/code&gt; part of the condition to handle missing values.
Normally a Datalog query will fail if we are trying to bind a value
that does not exist. Using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;if&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;case&lt;/code&gt; allows us to sidestep
that issue entirely.&lt;/p&gt;

&lt;h3 id=&quot;tag-joining&quot;&gt;Tag joining&lt;/h3&gt;
&lt;p&gt;Some of you may have noticed that these are different
from how special predicates are usually done in Datalog.
Specifically, the predicate (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;if&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;case&lt;/code&gt;) is the second term of 
the clause and not the first. Idiomatically it should be the other 
way around.&lt;/p&gt;

&lt;p&gt;There are a couple of reasons for this. First, Datalog clauses
typically don’t have separate output bindings so those are a bit 
clearer if they
are outside the body of the special condition.&lt;/p&gt;

&lt;p&gt;Secondly and more importantly, this puts the output variable at 
the beginning of the tag. This allows us to add some syntactic sugar
to make the user’s load a little lighter with tag joining.&lt;/p&gt;

&lt;p&gt;Consider this extended checkbox example:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IMAGE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IMAGE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CHECKED&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;empty&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Notice how the user has to separate the image selection logic
from where it’s used? How they have to name the variable even
though they use it once?&lt;/p&gt;

&lt;p&gt;This is why in Enaml there is a special syntax for joining tags.
It uses the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;%&lt;/code&gt; character to omit the variable so this is 
the equivalent of the above:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CHECKED&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;empty&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Which removes 11 characters, has no need to come up with a variable
name and visually connects the two pieces of data.&lt;/p&gt;

&lt;h2 id=&quot;effect-tag&quot;&gt;Effect tag&lt;/h2&gt;
&lt;p&gt;On to the effect tag, which determines post-conditions for the node:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;toggle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SYSTEM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sound&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;on&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;They are similar to (pre-)conditions that they are ultimately turned
into Datalog, but in this case datoms. Where pre-conditions read the
database, effects write to it.&lt;/p&gt;

&lt;p&gt;The first term is always the type of effect and the rest are parameters.
Here the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;toggle&lt;/code&gt; effect sets an entity attribute to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt;,
which is useful for checkboxes and flags.&lt;/p&gt;

&lt;h3 id=&quot;addition-and-retraction&quot;&gt;Addition and retraction&lt;/h3&gt;
&lt;p&gt;There are two syntactic sugar variations on the effect, addition:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PLAYER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mood&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;angry&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Which turns into:&lt;/p&gt;
&lt;div class=&quot;language-clojure highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:db/add&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;?PLAYER&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:mood&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:angry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;and retraction:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PLAYER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mood&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;angry&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Which turns into:&lt;/p&gt;
&lt;div class=&quot;language-clojure highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:db/retract&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;?PLAYER&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:mood&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:angry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;You can also retract an entire entity if you leave out the rest of
the tag, like so:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PLAYER&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Together with conditions there’s obviously a lot here Enaml can do 
to reduce boilerplate by making special conditions and effects.&lt;/p&gt;

&lt;p&gt;I’m also
thinking the user should be able to define their own composite 
functions as well. But that has not been implemented, at least not yet.
They wouldn’t require any special syntax so not relevant here either way.&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;This post was getting long so I separated the advanced tags into their
own post.
See the &lt;a href=&quot;/enaml-part-3&quot;&gt;next part&lt;/a&gt;
for the juicy advanced stuff.&lt;/p&gt;
</description>
        <pubDate>Wed, 28 Oct 2026 00:00:00 +0200</pubDate>
        <link>https://wwww.sacredlake.systems/enaml-part-2</link>
        <guid isPermaLink="true">https://wwww.sacredlake.systems/enaml-part-2</guid>
        
        <category>Enaml</category>
        
        <category>Dev</category>
        
        
      </item>
    
      <item>
        <title>Enaml - part 1</title>
        <description>&lt;p&gt;After going through the plan for 2026 
&lt;a href=&quot;/milestones-for-2026&quot;&gt;last time&lt;/a&gt;
and musing about game engines
&lt;a href=&quot;/making-engines&quot;&gt;the week before&lt;/a&gt;, 
it’s finally time to get into the thick of it.&lt;/p&gt;

&lt;p&gt;This is the first part of a series of posts that will go through the Domain Specific Language (DSL)
I’ve created for developing my games, called Enaml. 
This first post will go through the basics so I can get to the
good parts today. Later I will talk about inspirations and specifics.&lt;/p&gt;

&lt;h1 id=&quot;basic-structure&quot;&gt;Basic structure&lt;/h1&gt;
&lt;p&gt;The foundation of the language is really simple:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;A document is an ordered tree of nodes&lt;/li&gt;
  &lt;li&gt;Each node is a line in the document (with exceptions, see below)&lt;/li&gt;
  &lt;li&gt;Nodes have a single string template for text and/or a set of tags for data&lt;/li&gt;
  &lt;li&gt;Terms in all-caps are variables, other terms are constants&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whitespace matters; the nodes’ locations are determined with indentation.
There’s also comments and some tags do funky things but otherwise that’s pretty much it for the basics.&lt;/p&gt;

&lt;h1 id=&quot;example&quot;&gt;Example&lt;/h1&gt;
&lt;p&gt;The above definition is pretty high level so here’s an example bit of menu definition:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;menu&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SYSTEM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;menu&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;New game&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SYSTEM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;menu&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;game&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;Load game&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SYSTEM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;menu&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;game&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;Quit&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;quit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;(I’m looking into custom highlighting but for now I’m using C highlighting as a placeholder)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Because I am programming with Clojure, in practice this gets turned into an 
&lt;a href=&quot;https://github.com/edn-format/edn&quot;&gt;EDN&lt;/a&gt; data structure for the code to read,
which would look like this:&lt;/p&gt;
&lt;div class=&quot;language-clojure highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/key&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; locally unique key for this node&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/path&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; full path to this node; also node&apos;s GUID&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:flow&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:y&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; this makes children form a column&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/conditions&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;&apos;?SYSTEM&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; datalog :where clauses&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/children&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/key&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:_0&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; automatically determined&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/path&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:_0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; note parent key :menu in path&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/text&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;New game&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/effects&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:db/add&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;&apos;?SYSTEM&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:new-game&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/key&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:_1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/path&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:_1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/text&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Load game&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/effects&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:db/add&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;&apos;?SYSTEM&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:load-game&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/key&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:_2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/path&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:_2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/text&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Quit&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/effects&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:quit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]}]}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Of course this is a little unfair to compare these since above we use some tricks to make
authoring easier like automatic keys and paths. 
We could also do these for the EDN. So here’s a more author-friendly version of the above EDN:&lt;/p&gt;
&lt;div class=&quot;language-clojure highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/key&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:flow&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:y&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/conditions&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;&apos;?SYSTEM&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/children&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/text&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;New game&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/effects&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:db/add&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;&apos;?SYSTEM&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:new-game&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/text&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Load game&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/effects&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:db/add&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;&apos;?SYSTEM&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:menu&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:load-game&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/text&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Quit&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:node/effects&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;:quit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]}]}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is more reasonable. You could definitely write this by hand.&lt;/p&gt;

&lt;p&gt;But it still has more than double the number of lines and more than three times the number of characters
(including whitespace) than the Enaml version. But more than that you can also see that further nesting
would quickly make the line width go out of control.&lt;/p&gt;

&lt;p&gt;You could alleviate this a bit by removing the namespaces from the keywords.
Or flattening the effects and conditions to dot-notated keywords.
But that only removes a fraction of the characters. 
And you would still need to write a lot of boilerplate for the keywords.&lt;/p&gt;

&lt;p&gt;There’s also other benefits that don’t really shine here since this example is so simple.
Like custom syntax highlighting and special syntax for multiline strings, etc.&lt;/p&gt;

&lt;h1 id=&quot;benefits-and-drawbacks-of-a-dsl&quot;&gt;Benefits and drawbacks of a DSL&lt;/h1&gt;
&lt;p&gt;Now am I claiming Enaml is superior to EDN? Of course not. 
This example is so egregious because Enaml is a language for a very specific purpose
while EDN is a generic data notation language for all kinds of things.&lt;/p&gt;

&lt;p&gt;For one, I already know the schema the data is supposed to fill. I know that effects and conditions
are parsed into Datalog queries and transactions. I know that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;flow&lt;/code&gt; is a single scalar value and
others are vectors or maps.&lt;/p&gt;

&lt;p&gt;There’s also limitations. For example, Enaml does not currently support floating point numbers.
It doesn’t really play well with the dot notation used for tags. I could add special syntax for it
if really necessary but for now it has not been.&lt;/p&gt;

&lt;p&gt;And as stated above, a node can have only one string value. Other strings have to be added as child nodes.&lt;/p&gt;

&lt;p&gt;This means the data is also a little unoptimized. Enaml does not care if you are making a map, list or set.
A node is always a hash-map with a vector of child nodes.&lt;/p&gt;

&lt;p&gt;For an opposite example, the worst case scenario for Enaml is something like this:&lt;/p&gt;
&lt;div class=&quot;language-clojure highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;apples&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;oranges&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;bananas&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;pears&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;grapes&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Which would need six lines to reproduce as Enaml (left as an exercise for the reader).
Actually, a nested set of vectors, maps and sets would be even worse.
But that’s not really a good idea with
EDN either.&lt;/p&gt;

&lt;p&gt;But these are trade-offs you can (and should) make when designing a Domain Specific Language.
The whole point is to focus on the things that matter to your use case.&lt;/p&gt;

&lt;p&gt;As with engines, you should only make your own if existing ones don’t meet your needs, and you
should know what those needs are.&lt;/p&gt;

&lt;h1 id=&quot;next-time&quot;&gt;Next time&lt;/h1&gt;
&lt;p&gt;You can probably deduce a lot of the functions here from these examples, at least if you know EDN.
Next time in &lt;a href=&quot;/enaml-part-2&quot;&gt;part 2&lt;/a&gt; and &lt;a href=&quot;/enaml-part-3&quot;&gt;part 3&lt;/a&gt;
I’m going to go more into detail though and go through all the tag types, including
ones we didn’t see here like inheritance or overwrite tags.&lt;/p&gt;

&lt;p&gt;Until then, hope you have a good week.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;EDIT 2026-10-27&lt;/em&gt;: Reading this now, looks like I forgot to mention something a DSL has
over an existing format and I don’t want you to think that brevity is the only thing I care about.
One other deciding benefit of a DSL is that I can attach source metadata to nodes and use it when
an error arises.&lt;/p&gt;

&lt;p&gt;The error message can then point to the exact file and line number the author should go for debugging,
instead of an abstract path. Next time you will see how this is relevant for data inheritance and 
flexible file composition.&lt;/p&gt;
</description>
        <pubDate>Wed, 21 Oct 2026 00:00:00 +0300</pubDate>
        <link>https://wwww.sacredlake.systems/enaml-part-1</link>
        <guid isPermaLink="true">https://wwww.sacredlake.systems/enaml-part-1</guid>
        
        <category>Enaml</category>
        
        <category>Dev</category>
        
        
      </item>
    
      <item>
        <title>Milestones for 2026</title>
        <description>&lt;p&gt;&lt;a href=&quot;/making-engines&quot;&gt;Last time&lt;/a&gt; I talked about making engines and why what I am doing doesn’t
really fit nicely into that category so if you’re new here you should probably read that first.&lt;/p&gt;

&lt;p&gt;Today I’ll be talking about my plans for the rest of the year and the three milestones I 
want to accomplish this year.&lt;/p&gt;

&lt;p&gt;I’m going to implement the “engine” in parts. This will help guide my development towards
measurable progress and hopefully prevent me from getting lost in the weeds on some
unimportant side feature. It should also validate my progress with regular checkpoints to
see if I’ve missed a necessary feature.&lt;/p&gt;

&lt;p&gt;I’ve chosen each milestone to be something that could itself be used to make a simple game.
Further milestones just give more capabilities to play with.&lt;/p&gt;

&lt;p&gt;Also, these lists may change as I find out that a given feature actually requires something else
to work. One of the purposes of the milesto&lt;/p&gt;

&lt;h1 id=&quot;1st-milestone-a-slideshow&quot;&gt;1st milestone: A slideshow&lt;/h1&gt;
&lt;p&gt;This is actually already done!
Basically, the engine has to be able to handle a slideshow.&lt;/p&gt;

&lt;p&gt;Even this entails a surprising number of things:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Display text (not bitmap fonts, we’re not in the 90s)&lt;/li&gt;
  &lt;li&gt;Display images (including &lt;a href=&quot;https://en.wikipedia.org/wiki/9-slice_scaling&quot;&gt;9-slice scaling&lt;/a&gt; for UI)&lt;/li&gt;
  &lt;li&gt;Layout algorithm (with support for flex elements)&lt;/li&gt;
  &lt;li&gt;Responsive scaling (for different sizes of screens)&lt;/li&gt;
  &lt;li&gt;Store state (for which slide you are on)&lt;/li&gt;
  &lt;li&gt;Conditionals (for showing the correct slide based on state)&lt;/li&gt;
  &lt;li&gt;Mouse input (for changing the slide when user clicks)&lt;/li&gt;
  &lt;li&gt;Domain specific language (for defining the contents of the slides and storing them)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of course, the point is not only to blindly implement the bare minimum for these.&lt;br /&gt;
Each of these has been done so they support continued development and (hopefully) do not 
need to be returned to. For example, the last four items use
&lt;a href=&quot;https://github.com/tonsky/datascript&quot;&gt;DataScript&lt;/a&gt; to enable the future creation of
arbitrary state and events. It’s not just a hardcoded variable for which slide we are on or
a function for incrementing it.&lt;/p&gt;

&lt;p&gt;Most of these are also backend agnostic so the layout function is pure CLJC files, as is the
language implementation.&lt;/p&gt;

&lt;p&gt;This could already be used to make a very simple CYOA style game. 
But this is not enough, so on we go to the second milestone.&lt;/p&gt;

&lt;h1 id=&quot;2nd-milestone-cloak-of-darkness&quot;&gt;2nd milestone: Cloak of Darkness&lt;/h1&gt;
&lt;p&gt;The second milestone is currently ongoing. The idea is to enable the things needed for a simple
text adventure. For this, I will be using &lt;a href=&quot;https://www.ifwiki.org/Cloak_of_Darkness&quot;&gt;Cloak of Darkness&lt;/a&gt;
as a benchmark. As stated on the IFWiki, the adventure is really basic and is designed to be easy
to port to a given interactive fiction authoring system to see what it’s like. 
I am making one of those so this is a good spot to check how well it’s handled.&lt;/p&gt;

&lt;p&gt;We need several new features to properly implement the game:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Widget state (hover and focus for buttons)&lt;/li&gt;
  &lt;li&gt;Entity notation (for defining the rooms and objects)&lt;/li&gt;
  &lt;li&gt;Text templates (for displaying current room description)&lt;/li&gt;
  &lt;li&gt;Loops (for listing carried objects)&lt;/li&gt;
  &lt;li&gt;Event system (incl. &lt;a href=&quot;https://en.wikipedia.org/wiki/Event-driven_programming#Event_handlers&quot;&gt;handlers&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Guard_(computer_science)&quot;&gt;guards&lt;/a&gt; on player actions)&lt;/li&gt;
  &lt;li&gt;Undo, restart and restore (standard adventure state handling)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This should take us most of the way. But we still need polish and UX improvements so on we go to the
third milestone.&lt;/p&gt;

&lt;h1 id=&quot;3rd-milestone-the-question&quot;&gt;3rd milestone: The Question&lt;/h1&gt;
&lt;p&gt;This mostly includes features that make the games look or sound better.
For this the system should be able to handle &lt;a href=&quot;https://www.renpy.org/doc/html/thequestion.html#thequestion&quot;&gt;The Question&lt;/a&gt;,
the quickstart script for the Ren’Py visual novel engine.&lt;/p&gt;

&lt;p&gt;I’m also adding some features not included in The Question and ignoring some it has.&lt;/p&gt;

&lt;p&gt;Without further ado:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Music and sound (often neglected but important)&lt;/li&gt;
  &lt;li&gt;Shaders (for pizzazz!)&lt;/li&gt;
  &lt;li&gt;Transforms (see doc &lt;a href=&quot;https://www.renpy.org/doc/html/transforms.html#transforms&quot;&gt;here&lt;/a&gt;)&lt;/li&gt;
  &lt;li&gt;Loading screen (to display during asset preloading)&lt;/li&gt;
  &lt;li&gt;Options menu (for volume at least)&lt;/li&gt;
  &lt;li&gt;Keyboard and gamepad support (including tab for changing UI focus)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here the third item is doing most of the heavy lifting; the Ren’Py transformations include
&lt;a href=&quot;https://www.renpy.org/doc/html/transforms.html#warpers&quot;&gt;tween animations&lt;/a&gt;, image positioning and more.&lt;/p&gt;

&lt;p&gt;There may be more items I want to add here as I go on. 
For example, I am unsure if I need a separate construct for longer “script” like sections
like is typical for visual novels.
But this should do for now.&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;As you can see from the above, the lists do not include a lot of possible features that you might expect,
like 3D graphics, physics, animation, etc.&lt;br /&gt;
Like I said last time, making this type of thing you really want to focus on a specific type
of game.&lt;/p&gt;

&lt;p&gt;Here my focus is to support making turn based 2D games with relatively simple interfaces
and high amounts of procedurality. If I wanted to make 3D or real-time games I would most 
likely choose an existing engine like &lt;a href=&quot;https://godotengine.org/&quot;&gt;Godot&lt;/a&gt; 
or &lt;a href=&quot;https://www.unrealengine.com/&quot;&gt;Unreal&lt;/a&gt; and use that instead. On the other hand if I
wanted to make interactive fiction that was mostly about an authored storyline with dynamic bits
I would use something like &lt;a href=&quot;https://www.renpy.org/&quot;&gt;Ren’Py&lt;/a&gt; or &lt;a href=&quot;https://www.inklestudios.com/ink/&quot;&gt;Ink&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But this is getting off-topic. I might make a separate post about this again, but I am done speaking
about engines and plans for now. Hopefully next time I’ll be able to get into implementation details.&lt;/p&gt;

&lt;p&gt;Until that time, hope you are doing well.&lt;/p&gt;
</description>
        <pubDate>Wed, 14 Oct 2026 00:00:00 +0300</pubDate>
        <link>https://wwww.sacredlake.systems/milestones-for-2026</link>
        <guid isPermaLink="true">https://wwww.sacredlake.systems/milestones-for-2026</guid>
        
        <category>General</category>
        
        
      </item>
    
      <item>
        <title>Making engines</title>
        <description>&lt;p&gt;I wanted to make this post about my planned milestones for 2026 but realized I
have to talk about engines in general first because it will keep popping up otherwise.&lt;/p&gt;

&lt;h1 id=&quot;why-not-to-make-a-game-engine&quot;&gt;Why not to make a game engine&lt;/h1&gt;

&lt;p&gt;The one thing everyone knows about game development is that you should not start 
by making your own game engine. At least not if you want to ship a game at some point.&lt;/p&gt;

&lt;p&gt;Making a full-fledged game engine is a much bigger project than making a game.
There are plenty of game jams; there are no game engine jams.
Of course one part of it is that using someone’s game engine is a lot more work than playing
someone’s game.&lt;/p&gt;

&lt;p&gt;But that’s also the point. It is very unlikely that anyone is going to use your game engine,
even if you finish and publish it.
There are after all, ones with more features, better documentation and more frequent updates.&lt;/p&gt;

&lt;p&gt;There are a couple of reasons to roll your own tech, however:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;You are doing it for fun&lt;/li&gt;
  &lt;li&gt;No existing engine does what you want&lt;/li&gt;
  &lt;li&gt;You are making an engine for a specific type of game&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now number one is pretty self-explanatory. Learning is fun and everyone needs a hobby.&lt;/p&gt;

&lt;p&gt;Number two is more interesting and there is a lot of room to be weaselly here.
Is your game idea really that special? There is probably a plugin or extension you can use
(or create yourself) instead of creating a whole game engine.&lt;/p&gt;

&lt;p&gt;Number three is kind of what I am doing. Instead of creating a generic engine like Unreal or Godot,
you should focus on what you actually need and want for your projects.&lt;/p&gt;

&lt;h1 id=&quot;not-really-making-a-game-engine&quot;&gt;Not really making a game engine&lt;/h1&gt;

&lt;p&gt;I am not really making an engine. 
I’ve thought about what words to use to describe it but none of them really fit.
What I really am building is a virtual machine, like the &lt;a href=&quot;https://en.wikipedia.org/wiki/Z-machine&quot;&gt;Z-machine&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;However, if I talk about a virtual machine, most people will not know what I am talking about,
and most of the rest of them will think I am talking about operating system emulation or cloud computing.
So I will mostly refer to it as an engine.&lt;/p&gt;

&lt;p&gt;But yes, what I am making is a Domain Specific Language (DSL) for defining games 
and an interpreter for that language.
This is actually a common practice in interactive fiction.
In addition to the ZIL language for the Z-machine,
there is also a lot of other languages, the biggest ones being
&lt;a href=&quot;https://www.inklestudios.com/ink/&quot;&gt;Ink&lt;/a&gt;,
&lt;a href=&quot;https://ganelson.github.io/inform-website/doc/&quot;&gt;Inform&lt;/a&gt;,
&lt;a href=&quot;https://www.choiceofgames.com/make-your-own-games/choicescript-intro/&quot;&gt;ChoiceScript&lt;/a&gt;,
and so on.&lt;/p&gt;

&lt;h1 id=&quot;why-make-another-one&quot;&gt;Why make another one?&lt;/h1&gt;

&lt;p&gt;So why not use one of those instead?&lt;/p&gt;

&lt;p&gt;Well first of all, most of those are very specific. With that comes assumptions
about the type of game you’re making.&lt;/p&gt;

&lt;p&gt;For Ink and ChoiceScript those are that you are
expected to mostly be writing the text of your story while sprinkling dynamic bits into it.
There is very little support for more complicated world models (state management)
or role allocation (deciding which entities fill which parts).&lt;/p&gt;

&lt;p&gt;For Inform and other adventure game languages, there is better support for creating
an interactive world. But these then take a very simulation-first approach, where
the player is expected to be manipulating objects turn by turn. This strongly
guides you towards making a very specific type of game.&lt;/p&gt;

&lt;p&gt;Also, I am becoming more convinced that you should build your simulation on top of your game,
instead of trying to build a game on top of your simulation. But maybe more about that in a later post.&lt;/p&gt;

&lt;p&gt;So what I really want is a system that puts the game functionality first but which is generic
enough to create several types of menu based story games without lots of boilerplate.&lt;/p&gt;

&lt;h1 id=&quot;using-a-game-engine-anyway&quot;&gt;Using a game engine anyway&lt;/h1&gt;

&lt;p&gt;Now even if you are making your own language and interpreter, you still need to handle all the
other stuff a game engine would handle, like rendering graphics or handling user input.
For these I am actually using an engine (for browsers it’s &lt;a href=&quot;https://phaser.io/phaser4&quot;&gt;Phaser 4&lt;/a&gt;,
for desktop it will probably be &lt;a href=&quot;https://libgdx.com/&quot;&gt;LibGDX&lt;/a&gt;). But I am using it more like 
a software framework.&lt;/p&gt;

&lt;p&gt;The whole thing is basically:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;The game configuration files (written in the DSL)&lt;/li&gt;
  &lt;li&gt;That are interpreted by my code (written in Clojure)&lt;/li&gt;
  &lt;li&gt;Which communicates with the game engine (Phaser)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This has the benefit of all pieces being modular. So the files can be changed for each game
without touching the code, the code can handle standard stuff like saving and menus
that are the same from game to game and the engine can be switched if necessary.&lt;/p&gt;

&lt;p&gt;That last part is especially relevant now after Unity’s questionable choices in recent times.
And also because I want support for both browser and desktop. Even porting to console should be
easier with this setup.&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;There’s plenty more to talk about this, but I am trying to keep these posts relatively contained
and on topic. I didn’t even mention
&lt;a href=&quot;https://www.renpy.org/&quot;&gt;Ren’Py&lt;/a&gt;,
&lt;a href=&quot;https://versu.com/about/how-versu-works/&quot;&gt;Versu&lt;/a&gt; or
&lt;a href=&quot;https://en.wikipedia.org/wiki/SCUMM&quot;&gt;SCUMM&lt;/a&gt;. 
I’ll go into the details in later posts.&lt;/p&gt;

&lt;p&gt;Until then, look before you leap and think before writing your own game engine.&lt;br /&gt;
See you next time.&lt;/p&gt;
</description>
        <pubDate>Wed, 07 Oct 2026 00:00:00 +0300</pubDate>
        <link>https://wwww.sacredlake.systems/making-engines</link>
        <guid isPermaLink="true">https://wwww.sacredlake.systems/making-engines</guid>
        
        <category>Dev</category>
        
        
      </item>
    
      <item>
        <title>About</title>
        <description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;My name is Aarne and I am a solo game developer based in Tampere, Finland.&lt;br /&gt;
This site will be a place for me to write down my thoughts and journal my progress.
The name of the site comes from Pyhäjärvi, a lake in Tampere I am particularly fond of.&lt;/p&gt;

&lt;p&gt;For the content itself, it will be a mix of more technical stuff about game programming, 
specific devlogs and more general game talk.
I may also do YouTube videos at some point. And maybe even a comments section. We’ll see.&lt;/p&gt;

&lt;p&gt;I am most interested in exploring the space between interactive fiction and more procedural game systems.
This is of course the holy grail of roleplaying video games; the dream of a digital
dungeon master. Ever since the 70s people have tried to capture the experience in electric form.
Colossal Cave Adventure, Rogue, Baldur’s Gate, Fallen London, Disco Elysium and countless
others have tried to capture that lighting in a bottle.&lt;/p&gt;

&lt;p&gt;Even after 50 years, I believe there’s still unexplored terrain here.
The recent explosion of solo tabletop roleplaying games in recent years is proof of that.
And the work of studios like Inkle and Failbetter show that it is possible to break new ground with
resources that on paper are miniscule compared to the average game company.&lt;/p&gt;

&lt;p&gt;But do not think me a delusional fool. I am well aware of the vagaries of game development 
and the risks associated with solo development in particular.
The most common of which is faffing about for years, never releasing anything.&lt;/p&gt;

&lt;p&gt;Woe be the projects folder of an excitable engineer.&lt;/p&gt;

&lt;p&gt;Wasted the desk drawer of a wannabe writer.&lt;/p&gt;

&lt;p&gt;I am writing this to you both to keep myself accountable and because reading these types of blogs
is one of the greatest pastimes I know. Yes, really. 
I want to give other people the joy I’ve gotten from reading these.
Maybe I’ll make a list of my favorites at some point.&lt;/p&gt;

&lt;p&gt;But that will have to wait. For now, join me on this quest.&lt;br /&gt;
Even if we fail we’ll at least have some fun and stories to share on the way.
Land among the stars, etc.&lt;/p&gt;

&lt;p&gt;You can email me at info@sacredlake.systems.&lt;/p&gt;

&lt;p&gt;P.S. I do not use generative AI or LLMs for this site or any of the things featured here.
See &lt;a href=&quot;/ai-policy&quot;&gt;this post&lt;/a&gt; for details.&lt;/p&gt;
</description>
        <pubDate>Mon, 28 Sep 2026 00:00:00 +0300</pubDate>
        <link>https://wwww.sacredlake.systems/about</link>
        <guid isPermaLink="true">https://wwww.sacredlake.systems/about</guid>
        
        <category>General</category>
        
        
      </item>
    
  </channel>
</rss>