<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Zig on mkz.me</title>
		<link>https://mkz.me/til/zig/</link>
		<description>Recent content in Zig on mkz.me</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Sun, 22 Sep 2024 10:17:15 +0200</lastBuildDate>
		
			<atom:link href="https://mkz.me/til/zig/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Objects modules in Zig with fieldParentPtr</title>
				<link>https://mkz.me/til/zig/objects-with-fieldparentptr/</link>
				<pubDate>Sun, 22 Sep 2024 10:17:15 +0200</pubDate>
				<guid>https://mkz.me/til/zig/objects-with-fieldparentptr/</guid>
				<description>&lt;p&gt;&lt;code&gt;fieldParentPtr&lt;/code&gt; can be useful in case it is required to create multiple kind of objects all based on a common type that can be passed to generic functions and then coerced to their original type. A usecase for this is a &lt;code&gt;Value&lt;/code&gt; object that then will contain &lt;code&gt;string&lt;/code&gt;, &lt;code&gt;number&lt;/code&gt;, &lt;code&gt;bool&lt;/code&gt;, &lt;code&gt;function&lt;/code&gt;, &lt;code&gt;instance&lt;/code&gt; when building a new language.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ mkdir zig-objects &lt;span class=&#34;o&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;cd&lt;/span&gt; zig-objects&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ zig init&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;info: created build.zig&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;info: created build.zig.zon&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;info: created src/main.zig&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;info: created src/root.zig&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;info: see &lt;span class=&#34;sb&#34;&gt;`&lt;/span&gt;zig build --help&lt;span class=&#34;sb&#34;&gt;`&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; a menu of options&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Defining the object in &lt;code&gt;object.zig&lt;/code&gt;:&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
