-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
207 lines (189 loc) · 11.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html lang="en_us">
<head>
<title>ParTcl</title>
<meta charset="utf-8" />
<meta name="generator" content="Pelican" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/static/css/main.css" />
<link rel="stylesheet" href="/static/css/theme.css" />
<link rel="icon" href="/images/yazani/yazani_1_extracted_bg_big_eyes_cropped.png" type="image/png" />
<link rel="apple-touch-icon" href="/images/yazani/yazani_1_extracted_bg_big_eyes_cropped.png" type="image/png" />
<script src="/static/misc.js"></script>
<script src="/blog/banner_image.js"></script>
<meta name="tags" content="programming, c" />
<meta property="og:site_name" content="dragoncoder047’s blog" />
<meta property="og:title" content="ParTcl" />
<meta property="og:description" content="C headers are annoying. I was getting fed up with uLisp and so I decided to run another Google search for “embeddable scripting language for Arduino”. It turned up mruby-arduino – poorly documented, and a little too big for my needs. It turned up eLua – which unfortunately is just a flashable …" />
<meta property="og:image" content="/images/yazani/yazani_1_extracted_bg.png" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://dragoncoder047.github.io/blog/2022/partcl" />
<meta property="og:locale" content="['']" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="dragoncoder047’s blog - ParTcl" />
<meta name="twitter:description" content="C headers are annoying. I was getting fed up with uLisp and so I decided to run another Google search for “embeddable scripting language for Arduino”. It turned up mruby-arduino – poorly documented, and a little too big for my needs. It turned up eLua – which unfortunately is just a flashable …" />
<meta name="twitter:image" content="/images/yazani/yazani_1_extracted_bg.png" />
<!-- PrismJS -->
<script src="/static/prism.js" data-autoloader-path="https://cdn.jsdelivr.net/npm/prismjs@v1.x/components/"></script>
<script src="/static/prism-runbutton.js"></script>
<script src="/phoo/prism-phoo.js"></script> <!-- /PrismJS -->
</head>
<body class="match-braces rainbow-braces">
<header>
<a href="https://dragoncoder047.github.io/blog" class="flex-row"><div class="flex-row"><img src="/images/yazani/yazani_1_extracted_bg.png" style="max-height:10em" id="banner-image" /><div id="sitename-text"><h1>dragoncoder047’s blog</h1><h2>random thoughts about nonrandom things</h2></div></div></a>
<nav>
<ul>
<li><a href="https://dragoncoder047.github.io/blog/">Home</a></li>
<li><a href="https://dragoncoder047.github.io/blog/archives">Archives</a>
</li>
<li><a href="https://dragoncoder047.github.io/blog/tags">By tag</a>
</li>
<li><a href="/">Site root</a>
</li>
<li><a href="#">Projects</a>
<ul>
<li><a href="https://dragoncoder047.github.io/thuepaste">Thuepaste</a>
</li>
<li><a href="https://dragoncoder047.github.io/armdroid">Armdroid</a>
</li>
<li><a href="https://dragoncoder047.github.io/langton-music">Langton's Ant Music</a>
</li>
<li><a href="https://dragoncoder047.github.io/schemascii">Schemascii</a>
</li>
<li><a href="https://dragoncoder047.github.io/parasite">Parasite</a>
</li>
</ul>
</li>
<li>
<form action="https://www.google.com/search" method="GET">
<input name="q" type="search" placeholder="Search"></input>
<input type="hidden" name="as_sitesearch" value="https://dragoncoder047.github.io/blog"></input>
<input type="submit" value="Search"></input>
</form>
</li>
</ul>
</nav>
</header>
<main>
<h1><a href="https://dragoncoder047.github.io/blog/2022/partcl" rel="bookmark" title="Permalink to this page">ParTcl</a></h1>
<div class="flex-row">
<span style="flex: 1">← Previous:
<a href="https://dragoncoder047.github.io/blog/2022/lisp-practice">
Lisp Practice
</a>
</span>
<span>Next:
<a href="https://dragoncoder047.github.io/blog/2022/scratching-my-head-again">
Scratching My Head Again
</a> →
</span>
</div>
<div class="post-info">
Posted <time class="published" datetime="2022-10-14T00:00:00-04:00">Fri 14 October 2022</time>
<address>By
<a href="https://dragoncoder047.github.io/blog/">dragoncoder047</a>
</address>
<div class="tags">
Tags:
<a href="https://dragoncoder047.github.io/blog/tag/c">c</a>
<a href="https://dragoncoder047.github.io/blog/tag/programming">programming</a>
</div>
</div>
<p><em>This post is part 2 of the arduino-scripting series:</em></p>
<ol class="series">
<li >
<a href='https://dragoncoder047.github.io/blog/2022/ulisp-thoughts'>uLisp Thoughts</a>
</li>
<li class="active">
<a href='https://dragoncoder047.github.io/blog/2022/partcl'>ParTcl</a>
</li>
<li >
<a href='https://dragoncoder047.github.io/blog/2022/scratching-my-head-again'>Scratching My Head Again</a>
</li>
<li >
<a href='https://dragoncoder047.github.io/blog/2022/some-unrelated-ideas'>Some Unrelated Ideas</a>
</li>
<li >
<a href='https://dragoncoder047.github.io/blog/2022/segfaults'>Segfaults</a>
</li>
<li >
<a href='https://dragoncoder047.github.io/blog/2023/lilduino'>LILduino</a>
</li>
</ol>
<p>C headers are annoying. I was getting fed up with uLisp and so I decided to run another Google search for “embeddable scripting language for Arduino”.</p>
<p>It turned up <a href="https://github.com/kyab/mruby-arduino">mruby-arduino</a> – poorly documented, and a little too big for my needs.</p>
<p>It turned up <a href="http://www.eluaproject.net/">eLua</a> – which unfortunately is just a flashable firmware with no C interface for custom functions (just like with MicroPython).</p>
<p>And it turned up Serge Zaitsev’s <a href="https://zserge.com/posts/tcl-interpreter/">ParTcl interpreter</a>. It’s a bare-bones interpreter for the <a href="https://en.wikipedia.org/wiki/Tcl">Tcl</a> programming language which implements only 5 core functions (<code class="language-tcl highlight">subst</code>, <code class="language-tcl highlight">set</code>, <code class="language-tcl highlight">while</code>, <code class="language-tcl highlight">if</code>, and <code class="language-tcl highlight">proc</code>) as well as <code class="language-tcl highlight">puts</code> and some math functions.</p>
<p>Despite this minimalism, it is simple to understand as most things are abstracted away into functions and datatypes – and, leveraging the fact that “everything in Tcl is a string,” <code class="language-c highlight">malloc</code> and <code class="language-c highlight">free</code> can be used easily for dynamic memory management.</p>
<p>Additionally, from the Github readme:</p>
<blockquote>
<ul>
<li>Can be extended with custom Tcl commands</li>
<li>Runs well on bare metal embedded MCUs (~10k of flash is required)</li>
</ul>
</blockquote>
<p>…which is exactly what I need to use it as an Arduino library!</p>
<p>There are a few bugs – namely this one:</p>
<blockquote>
<p>In the default implementation lists are implemented as raw strings that add some escaping (braces) around each item. It’s a simple solution that also reduces the code, but in some exotic cases the escaping can become wrong and invalid results will be returned.</p>
</blockquote>
<p>Using my experience from Lisp lists, I saw that Tcl lists could be implemented as a linked list as well. I <a href="https://github.com/zserge/partcl/issues/14">proposed it</a> and we’ll see what Serge says. I could probably fork ParTcl and add it myself anyway.</p>
<p>This seems like the best solution so far, and what I’ll probably go with.</p>
<p>One last thing, with the regard to the name – do you think ParTcl would run on a <a href="https://www.sparkfun.com/products/13774">Particle</a>?</p>
<hr />
<p><strong>Related Posts</strong></p>
<ul>
<li><a href="https://dragoncoder047.github.io/blog/2024/pointer-soup">Pointer Soup</a></li>
<li><a href="https://dragoncoder047.github.io/blog/2024/a-hash-mapped-mess">A Hash-Mapped Mess</a></li>
<li><a href="https://dragoncoder047.github.io/blog/2024/the-lesser-of-two-evils">The Lesser of Two Evils</a></li>
<li><a href="https://dragoncoder047.github.io/blog/2024/order-up">Order Up</a></li>
<li><a href="https://dragoncoder047.github.io/blog/2023/continuations-and-the-thunk-queue">Continuations and the thunk queue</a></li>
</ul>
<script src="https://giscus.app/client.js"
data-repo="dragoncoder047/blog"
data-repo-id="R_kgDOHCL60w"
data-category="Post Comments"
data-category-id="DIC_kwDOHCL6084CRxCW"
data-mapping="og:title"
data-reactions-enabled="1"
data-input-position="top"
data-theme="dark"
data-lang="en"
crossorigin="anonymous"
async
></script>
<section id="extras">
<div class="blogroll">
<ul>
<li><a href="https://www.conwaylife.com/">Conwaylife.com Forums</a></li>
<li><a href="https://www.python.org/">Python</a></li>
<li><a href="http://www.ulisp.com/">uLisp</a></li>
</ul>
</div>
<div class="social">
<ul>
<li><a href="https://github.com/dragoncoder047">dragoncoder047 on GitHub</a></li>
<li><a href="https://youtube.com/@dragoncoder047">dragoncoder047 on YouTube</a></li>
<li><a href="https://instagram.com/dragoncoder047/">dragoncoder047 on Instagram</a></li>
</ul>
</div>
</section>
</main>
<footer>
<address>
Site built by <a href="https://getpelican.com/">Pelican</a>
</address>
<a href="#" onclick="window.scrollTo({top: 0, left: 0});">Back to top</a>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XR0F89CCGK"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-XR0F89CCGK");
</script>
</footer>
</body>
</html>