<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged structs</title>
<link>https://coderlegion.com/tag/structs</link>
<description>Powered by Question2Answer</description>
<item>
<title>A struct is a data strucure, of course of course</title>
<link>https://coderlegion.com/25466/a-struct-is-a-data-strucure-of-course-of-course</link>
<description>&lt;p&gt;When I started designing this language, I had a lot of fundamental decisions to make. Among those, one of the easiest was whether or not to allow virtual functions in scrml &lt;code&gt;struct&lt;/code&gt;s.&lt;/p&gt;
&lt;p&gt;If I had chosen to include virtual functions; I would have just called these data strctures objects.&lt;/p&gt;
&lt;p&gt;If you were paying attention, you might see why.&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;struct&lt;/code&gt; is a data structure. Plain and simple. But, you see, it is within that simplicity,  the power is made plain.&lt;/p&gt;
&lt;p&gt;Lets  define a unit of data as a value over over a type ( x/T ). Some would claim that it is state over type. Philistines!&lt;/p&gt;
&lt;p&gt;State is data that is presently being witnessed.&lt;/p&gt;
&lt;p&gt;While this might seem like a trivial distinction. The real differentiation comes from the realization that state is not witnessed in piecemeal. it is accepted as a whole, or thrown out as invalid state.&lt;/p&gt;
&lt;p&gt;State is, therefore, immutable by nature.&lt;/p&gt;
&lt;p&gt;So then, what of structs? I'll cover that in the next article &quot;State. Why its not data.&quot;&lt;/p&gt;
&lt;p&gt;Just kidding.  I hope this next part is becoming more obvious.&lt;/p&gt;
&lt;p&gt;So are struct mutable? ... Depends. But, let the default be: the node-tree structure should be immutable. Hence, a user definable &lt;code&gt;struct&lt;/code&gt;ure. the values should mostly bi mutable, with each node mutation re-validated against it's type (or predicate if run-time validation is reqd)&lt;/p&gt;
&lt;p&gt;Simple. And because it's simple, we can analyze it, exhaustively.&lt;/p&gt;
&lt;p&gt;Enter enums,  engine, and other super-powers that &quot;objects&quot; just can't &lt;code&gt;match&lt;/code&gt; .)&lt;/p&gt;
</description>
<category>Tutorials</category>
<guid isPermaLink="true">https://coderlegion.com/25466/a-struct-is-a-data-strucure-of-course-of-course</guid>
<pubDate>Wed, 26 Aug 2026 21:09:52 +0000</pubDate>
</item>
</channel>
</rss>