Skip to content

Commit

Permalink
Automated publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Github Actions committed Feb 23, 2024
1 parent a0c744c commit eb32986
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion blog/2024-02-23-bindings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
<span class="line"><span style="color:#f8f8f2"> </span><span style="color:#f92672">if</span><span style="color:#f8f8f2">(binding)</span></span>
<span class="line"><span style="color:#f8f8f2"> { </span><span style="color:#f92672">return</span><span style="color:#f8f8f2"> binding-&gt;value; }</span></span>
<span class="line"><span style="color:#f8f8f2"> </span><span style="color:#f92672">return</span><span style="color:#f8f8f2"> </span><span style="color:#f92672">*</span><span style="color:#f8f8f2">root.</span><span style="color:#a6e22e">rlock</span><span style="color:#f8f8f2">();</span></span>
<span class="line"><span style="color:#f8f8f2">}</span></span></code></pre><h2>Binding conveyance</h2><p>There's one other neat thing about dynamic bindings which can't go unmentioned. When you make a new thread in Clojure, the current var overrides you have get copied over to the new thread. The same applies to async blocks in core.async. This allows you to set up some var state and push it to another thread without needing to rebuild everything. With core.async, each time your task becomes unparked, bindings are re-established to what they were before. This ends up being super convenient and can feel magical.<p>Thanks to Tim Baldridge for [his post](https://cognitect.com/blog/2016/9/15/works-on-my-machine-understanding-var-bindings-and-roots) on this stuff, which helped put it more into terms I could understand. My goal here has been to reiterate and elucidate.<h2>Status report</h2><p>Ok, so all of this is implemented in jank now. I could've just said that from the beginning, I know, but I get paid by the character still, I swear. jank doesn't have <code>future</code> yet, but everything is in place for binding conveyance. To go hand in hand with this, I tackled meta hints next, allowing us to do things like <code>^:dynamic</code> on a var.<h2>Meta hints</h2><p>This one doesn't get a big explanation. jank now supports hints in the form of <code>^:keyword</code>, as well as <code>^{:keyword true}</code>. Multiple hints can be specified, they can be nested, etc. Not many parts of jank are using these hints yet, since I didn't go through all existing code to update usages, but we can do that iteratively. See? I can be brief.<h2>What else?</h2><p>Well, my quarter was booked for the following tasks:<ul><li>🗹 Dynamic vars<li>🗹 Meta hints<li>☐ Syntax quoting<li>☐ Normalized interpolation syntax</ul><p>The first two are done and the latter two remain, to be done in the next month. But is that all I did in two months? Just dynamic vars and meta hints? Nah.<h2>Support for exceptions</h2><p>I've added support for the special <code>throw</code> form, as well as for <code>try/catch/finally</code>. Previously, I was using inline C++ to throw exceptions, but the work on the dynamic vars gave me a good excuse to get proper exception support in there. I needed to ensure bindings were gracefully handled in exceptional scenarios!<p>My plan is to do a compiler deep dive, next post, going into how exceptions were implemented in jank. Stay tuned for that.<h2>Escaped string literals</h2><p>jank previously didn't properly support strings like <code>&quot;foo \&quot;bar\&quot; spam&quot;</code>, since they require mutation in order to unescape them. This is an interesting edge case, because all of the other tokens within jank's lexer work based on memory mapped string views. String views allow jank's lexer to run without any dynamic allocations at all. However, for escaped strings, we need to allocate a string, since we need to mutate it when unescaping. It's straight-forward, but just something I hadn't tackled yet.<h2>Reader macros</h2><p>Since I was improving the reader to support meta hints, I figured I'd add reader macro support. In jank, you can now use <code>#_</code> to comment out forms. Also, you can use <code>#{}</code> to create sets. Finally, you can use <code>#?(:jank foo)</code> and <code>#?@(:jank [])</code> to conditionally read in jank code. The <code>:default</code> option is supported, too. Support for shorthand functions, regex values, and var quotes will be coming soon.<h2>New core functions and macros</h2><p>While implementing the above features, I also added support for the following vars in <code>clojure.core</code>:<ul><li><code>assert</code><li><code>when-not</code><li><code>comment</code><li><code>zipmap</code><li><code>binding</code><li><code>with-redefs</code><li><code>drop</code> (not lazy)<li><code>take-nth</code> (not lazy)</ul><p>Since jank doesn't have lazy sequences yet, some of these functions are a little hacky. Lazy sequences come next quarter, though, as well as <code>loop</code> support!<h2>Community involvement</h2><p>But wait, there's more! jank received its first non-trivial code contributions this quarter, from a helpful man named <a href="https://github.com/Samy-33">Saket Patel</a>. He's working on a <a href="https://github.com/Samy-33/lein-jank">jank plugin</a> for leiningen and it's currently in a state where you can set up a multi-file jank project and use <code>lein jank run</code> to make magic happen. 😁 He's also submitted some C++ improvements to aid in that quest and to help jank compile on Apple M1 hardware. I'll have a more detailed demonstration of this in my next development update.<p>On top of that, in order to get him set up for contributing, I've done the following:<ul><li>Added a <a href="https://github.com/jank-lang/jank/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a><li>Added a <a href="https://cla-assistant.io/jank-lang/jank">CLA</a>, which is managed by a bot that will prompt you to sign upon submitting a PR with a large enough<li>Added automated code formatting and re-formatted the whole codebase, using clang-format. I don't like the look of it, but at least it's consistent</ul><h2>Would you like to join in?</h2><ol><li>Join the community on <a href="https://clojurians.slack.com/archives/C03SRH97FDK">Slack</a><li>Join the design discussions or pick up a ticket on <a href="https://github.com/jank-lang/jank">GitHub</a><li>Considering becoming a <a href="https://github.com/sponsors/jeaye">Sponsor</a> ❤️<li><strong>Hire me full-time to work on jank!</strong></ol></div></div></section></div><footer class="footer"><div class="container"><div class="columns has-text-centered"><div class="column has-text-centered"><aside class="menu"><p class="menu-label">Resources<ul class="menu-list"><li><a href="https://clojurians.slack.com/archives/C03SRH97FDK">Slack</a><li><a href="https://github.com/jank-lang/jank">Github</a><li><a href="https://jank-lang.org/blog/feed.xml">RSS</a></ul></aside></div></div><div class="container has-text-centered"><div class="content is-small"><p>© 2022 Jeaye Wilkerson | All rights reserved.</div></div></div></footer><noscript><p><img src="//matomo.jeaye.com/matomo.php?idsite=1&amp;rec=1"style="border:0"alt=""></p></noscript><script>for(var coll=document.getElementsByClassName("collapsible"),i=0;i<coll.length;i++)coll[i].addEventListener("click",function(){this.classList.toggle("active");var l=this.nextElementSibling;"block"===l.style.display?l.style.display="none":l.style.display="block"})</script>
<span class="line"><span style="color:#f8f8f2">}</span></span></code></pre><h2>Binding conveyance</h2><p>There's one other neat thing about dynamic bindings which can't go unmentioned. When you make a new thread in Clojure, the current var overrides you have get copied over to the new thread. The same applies to async blocks in core.async. This allows you to set up some var state and push it to another thread without needing to rebuild everything. With core.async, each time your task becomes unparked, bindings are re-established to what they were before. This ends up being super convenient and can feel magical.<p>Thanks to Tim Baldridge for <a href="https://cognitect.com/blog/2016/9/15/works-on-my-machine-understanding-var-bindings-and-roots">his post</a> on this stuff, which helped put it more into terms I could understand. My goal here has been to reiterate and elucidate.<h2>Status report</h2><p>Ok, so all of this is implemented in jank now. I could've just said that from the beginning, I know, but I get paid by the character still, I swear. jank doesn't have <code>future</code> yet, but everything is in place for binding conveyance. To go hand in hand with this, I tackled meta hints next, allowing us to do things like <code>^:dynamic</code> on a var.<h2>Meta hints</h2><p>This one doesn't get a big explanation. jank now supports hints in the form of <code>^:keyword</code>, as well as <code>^{:keyword true}</code>. Multiple hints can be specified, they can be nested, etc. Not many parts of jank are using these hints yet, since I didn't go through all existing code to update usages, but we can do that iteratively. See? I can be brief.<h2>What else?</h2><p>Well, my quarter was booked for the following tasks:<ul><li>🗹 Dynamic vars<li>🗹 Meta hints<li>☐ Syntax quoting<li>☐ Normalized interpolation syntax</ul><p>The first two are done and the latter two remain, to be done in the next month. But is that all I did in two months? Just dynamic vars and meta hints? Nah.<h2>Support for exceptions</h2><p>I've added support for the special <code>throw</code> form, as well as for <code>try/catch/finally</code>. Previously, I was using inline C++ to throw exceptions, but the work on the dynamic vars gave me a good excuse to get proper exception support in there. I needed to ensure bindings were gracefully handled in exceptional scenarios!<p>My plan is to do a compiler deep dive, next post, going into how exceptions were implemented in jank. Stay tuned for that.<h2>Escaped string literals</h2><p>jank previously didn't properly support strings like <code>&quot;foo \&quot;bar\&quot; spam&quot;</code>, since they require mutation in order to unescape them. This is an interesting edge case, because all of the other tokens within jank's lexer work based on memory mapped string views. String views allow jank's lexer to run without any dynamic allocations at all. However, for escaped strings, we need to allocate a string, since we need to mutate it when unescaping. It's straight-forward, but just something I hadn't tackled yet.<h2>Reader macros</h2><p>Since I was improving the reader to support meta hints, I figured I'd add reader macro support. In jank, you can now use <code>#_</code> to comment out forms. Also, you can use <code>#{}</code> to create sets. Finally, you can use <code>#?(:jank foo)</code> and <code>#?@(:jank [])</code> to conditionally read in jank code. The <code>:default</code> option is supported, too. Support for shorthand functions, regex values, and var quotes will be coming soon.<h2>New core functions and macros</h2><p>While implementing the above features, I also added support for the following vars in <code>clojure.core</code>:<ul><li><code>assert</code><li><code>when-not</code><li><code>comment</code><li><code>zipmap</code><li><code>binding</code><li><code>with-redefs</code><li><code>drop</code> (not lazy)<li><code>take-nth</code> (not lazy)</ul><p>Since jank doesn't have lazy sequences yet, some of these functions are a little hacky. Lazy sequences come next quarter, though, as well as <code>loop</code> support!<h2>Community involvement</h2><p>But wait, there's more! jank received its first non-trivial code contributions this quarter, from a helpful man named <a href="https://github.com/Samy-33">Saket Patel</a>. He's working on a <a href="https://github.com/Samy-33/lein-jank">jank plugin</a> for leiningen and it's currently in a state where you can set up a multi-file jank project and use <code>lein jank run</code> to make magic happen. 😁 He's also submitted some C++ improvements to aid in that quest and to help jank compile on Apple M1 hardware. I'll have a more detailed demonstration of this in my next development update.<p>On top of that, in order to get him set up for contributing, I've done the following:<ul><li>Added a <a href="https://github.com/jank-lang/jank/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a><li>Added a <a href="https://cla-assistant.io/jank-lang/jank">CLA</a>, which is managed by a bot that will prompt you to sign upon submitting a PR with a large enough<li>Added automated code formatting and re-formatted the whole codebase, using clang-format. I don't like the look of it, but at least it's consistent</ul><h2>Would you like to join in?</h2><ol><li>Join the community on <a href="https://clojurians.slack.com/archives/C03SRH97FDK">Slack</a><li>Join the design discussions or pick up a ticket on <a href="https://github.com/jank-lang/jank">GitHub</a><li>Considering becoming a <a href="https://github.com/sponsors/jeaye">Sponsor</a> ❤️<li><strong>Hire me full-time to work on jank!</strong></ol></div></div></section></div><footer class="footer"><div class="container"><div class="columns has-text-centered"><div class="column has-text-centered"><aside class="menu"><p class="menu-label">Resources<ul class="menu-list"><li><a href="https://clojurians.slack.com/archives/C03SRH97FDK">Slack</a><li><a href="https://github.com/jank-lang/jank">Github</a><li><a href="https://jank-lang.org/blog/feed.xml">RSS</a></ul></aside></div></div><div class="container has-text-centered"><div class="content is-small"><p>© 2022 Jeaye Wilkerson | All rights reserved.</div></div></div></footer><noscript><p><img src="//matomo.jeaye.com/matomo.php?idsite=1&amp;rec=1"style="border:0"alt=""></p></noscript><script>for(var coll=document.getElementsByClassName("collapsible"),i=0;i<coll.length;i++)coll[i].addEventListener("click",function(){this.classList.toggle("active");var l=this.nextElementSibling;"block"===l.style.display?l.style.display="none":l.style.display="block"})</script>
Loading

0 comments on commit eb32986

Please sign in to comment.