<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://amyparent.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://amyparent.com/" rel="alternate" type="text/html" /><updated>2025-03-09T18:45:45+00:00</updated><id>https://amyparent.com/feed.xml</id><title type="html">Amy Parent</title><subtitle>I&apos;m Amy (she/her), a queer, trans astrophysics &amp; computer science PhD student based in Dundee. In my spare time, I skate for Dundee Roller Derby, play games and make programming languages.
</subtitle><author><name>Amy Parent</name></author><entry><title type="html">An Ode to Inconceivable!</title><link href="https://amyparent.com/blog/incon_ceivable.html" rel="alternate" type="text/html" title="An Ode to Inconceivable!" /><published>2020-11-15T00:00:00+00:00</published><updated>2020-11-15T00:00:00+00:00</updated><id>https://amyparent.com/blog/incon_ceivable</id><content type="html" xml:base="https://amyparent.com/blog/incon_ceivable.html"><![CDATA[<p><img src="/static/media/2020/1115-incon_ceivable.jpg" alt="Inconceivable cover art" class="left" /></p>

<p>Quarantine has been (still is, really) hard. I live on my own, and as much as I can be very introverted at times, I draw a <em>lot</em> of my energy from interacting with my friends. I am also a pretty tactile person, so, there’s that. Suffice to say, I haven’t had the most sparkliest time these last 9 months (still, everyone. Stay home. Wear a mask. It works).</p>

<p>With time I’ve come up with a variety of coping mechanisms: reading (a lot of) fanfiction, books, drawing, binging shows, long calls with my best pals. Another one of these things is <a href="https://www.theincomparable.com/gameshow/inconceivable/"><em>Inconceivable</em></a>. <span class="right-float gui sidenote">
    Notice how “work” and “writing my thesis” doesn’t feature at all in that list? Yeah, me neither.
</span>
 I’ve known and listened to this podcast for ages now, but it’s been a really nice way to escape and just laugh – I’m pretty sure I’ve listened to all the episodes again at least twice in the last nine months.</p>

<blockquote>
  <p>Inconceivable! is a show that tests our panelists’ knowledge of the nerdy, the useless, and the obscure. Each episode, two teams face off to answer diabolical questions about TV shows, comics, movies, books, games, and more. Host Dan Moren and scorekeeper/announcer Lex Friedman oversee the proceedings, doling out hard-earned points where appropriate.</p>

  <p>– The Incomparable, <a href="https://www.theincomparable.com/gameshow/inconceivable/"><em>Inconceivable</em></a></p>
</blockquote>

<p><em>Inconceivable</em> is essentially a trivia panel show. But instead of it being about science, literature, sports and history, it’s nerdy films, TV and books, betting points on fake definitions, and outrageous, delightful punny movie title mashups. Dan Moren hosts, and Lex Friedman usually keeps the scores. Most of all, it’s <em>so much fun</em>.</p>

<p>The guests on the show all know each other (they’re all members of the <a href="https://www.theincomparable.com">Incomparable</a> nerdy podcast network), and I think that’s what makes the game so fun to listen to: after a couple episodes, it feels like you know them. You know Liz Myles will find the answer seemingly out of nowhere, Steve Lutz will add “You fake off!” when the Fake-Off round begins, someone will groan at one of Dan’s puns. I am fully aware that this paragraph must read like inane rambling, but I genuinely don’t think any description can do justice to how funny this show is. I have laughed so much I’ve cried at it.</p>

<p>I wish I had a more concise and put-together point, but really, the only thing I’d like to say is: go listen to Inconceivable. If you like fantasy, sci-fi, and puns, you <em>will</em> love it. If you don’t know where to start, I would recommend <a href="https://www.theincomparable.com/gameshow/78/">“There are no hamburgers in the Phantom Zone”</a>: the episode devolves into beautiful chaos and has had me crying every time I’ve listened to it, and includes some 10/10 Schwarzeneger impersonations.</p>]]></content><author><name>Amy Parent</name></author><category term="podcasts" /><summary type="html"><![CDATA[Quarantine has been (still is, really) hard. I live on my own, and as much as I can be very introverted at times, I draw a lot of my energy from interacting with my friends. I am also a pretty tactile person, so, there’s that. Suffice to say, I haven’t had the most sparkliest time these last 9 months (still, everyone. Stay home. Wear a mask. It works). With time I’ve come up with a variety of coping mechanisms: reading (a lot of) fanfiction, books, drawing, binging shows, long calls with my best pals. Another one of these things is Inconceivable. Notice how “work” and “writing my thesis” doesn’t feature at all in that list? Yeah, me neither. I’ve known and listened to this podcast for ages now, but it’s been a really nice way to escape and just laugh – I’m pretty sure I’ve listened to all the episodes again at least twice in the last nine months. Inconceivable! is a show that tests our panelists’ knowledge of the nerdy, the useless, and the obscure. Each episode, two teams face off to answer diabolical questions about TV shows, comics, movies, books, games, and more. Host Dan Moren and scorekeeper/announcer Lex Friedman oversee the proceedings, doling out hard-earned points where appropriate. – The Incomparable, Inconceivable Inconceivable is essentially a trivia panel show. But instead of it being about science, literature, sports and history, it’s nerdy films, TV and books, betting points on fake definitions, and outrageous, delightful punny movie title mashups. Dan Moren hosts, and Lex Friedman usually keeps the scores. Most of all, it’s so much fun. The guests on the show all know each other (they’re all members of the Incomparable nerdy podcast network), and I think that’s what makes the game so fun to listen to: after a couple episodes, it feels like you know them. You know Liz Myles will find the answer seemingly out of nowhere, Steve Lutz will add “You fake off!” when the Fake-Off round begins, someone will groan at one of Dan’s puns. I am fully aware that this paragraph must read like inane rambling, but I genuinely don’t think any description can do justice to how funny this show is. I have laughed so much I’ve cried at it. I wish I had a more concise and put-together point, but really, the only thing I’d like to say is: go listen to Inconceivable. If you like fantasy, sci-fi, and puns, you will love it. If you don’t know where to start, I would recommend “There are no hamburgers in the Phantom Zone”: the episode devolves into beautiful chaos and has had me crying every time I’ve listened to it, and includes some 10/10 Schwarzeneger impersonations.]]></summary></entry><entry><title type="html">How to Spot Comet NEOWISE</title><link href="https://amyparent.com/blog/neowise.html" rel="alternate" type="text/html" title="How to Spot Comet NEOWISE" /><published>2020-07-20T00:00:00+01:00</published><updated>2020-07-20T00:00:00+01:00</updated><id>https://amyparent.com/blog/neowise</id><content type="html" xml:base="https://amyparent.com/blog/neowise.html"><![CDATA[<p><img src="/static/media/2020/0700-neowise-101.png" alt="How to spot NEOWISE" /></p>]]></content><author><name>Amy Parent</name></author><category term="astronomy," /><category term="space" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">What the Planned Tory Reforms Mean for Trans Rights</title><link href="https://amyparent.com/blog/trans-rights.html" rel="alternate" type="text/html" title="What the Planned Tory Reforms Mean for Trans Rights" /><published>2020-06-15T12:10:00+01:00</published><updated>2020-06-15T12:10:00+01:00</updated><id>https://amyparent.com/blog/trans-rights</id><content type="html" xml:base="https://amyparent.com/blog/trans-rights.html"><![CDATA[<p>Do I have the spoons to do this? Nope. Am I still going to because everyone needs to be fighting this? yup.</p>

<p>TL;DR:</p>
<blockquote>
  <p>The UK tory government is planning a large-scale rollback of trans rights, including potential “bathroom bills”, on top of scrapping the much-needed reform to the Gender Recognition Act. If you are cis, your voice is more likely to be heard than ours. You can:</p>

  <ul>
    <li><a href="https://email.number10.gov.uk/">email no 10</a> and express your disagreement with the proposed transphobic laws.</li>
    <li><a href="https://www.writetothem.com/">email your MP</a> – and your MSP if you live in Scotland – to ask what they plan to do to support trans rights and oppose the reform.</li>
    <li>If you leave in Scotland, email the <a href="https://firstminister.gov.scot/join/first-minister-postbag/">First Minister</a> and ask her how she plans to support trans rights in Scotland.</li>
  </ul>

  <p>and <strong>Donate to organisations that support trans rights, especially black trans voices who are most vulnerable, and read up on trans rights:</strong></p>

  <ul>
    <li>Donate to <a href="http://genderedintelligence.co.uk/support-us/donate">Gendered Intelligence</a>. Read their <a href="http://genderedintelligence.co.uk/campaigns/baeb">Body Autonomy for Every Body</a> manifesto;</li>
    <li>Donate to the <a href="https://www.artsbusinesscollaborative.org/asp-products/black-trans-protestors-emergency-fund/">Black Trans Protestors Emergency Fund</a>;</li>
    <li>Donate to the <a href="https://www.artsbusinesscollaborative.org/asp-products/black-trans-femmes-in-the-arts-sponsored-projected_/">Black Trans Femmes in the Arts</a> supports;</li>
    <li>Donate to <a href="https://mermaidsuk.org.uk/">Mermaids</a> (supports Trans Youth &amp; their families);</li>
  </ul>

  <p><strong>Amplify trans voices, especially from black and indigenous trans communities. Listen. Speak up when you see transphobia.</strong></p>
</blockquote>

<p>I’ve seen a lot of people post to fight against the leaked tory plan to unravel UK trans rights (good!) but I think some are missing the bigger point. Which is probably exactly what the transphobic assholes want us to do, honestly. There’s four main points to what the government is apparently considering:</p>

<h2 id="killing-the-gra-reform">Killing the GRA reform</h2>

<p>That’s the one that people seem to be focused on. Not a single trans person is surprised by this move, we saw it coming light years away. The reform would have let trans people obtain a gender recognition certificate without going through gatekeeping and cis-normative doctors’ opinions, on the basis of self-declaration. This never had anything to do with bathrooms like TERFs would like you to believe. Trans people are already allowed to use the bathrooms that matches their gender without a GRC.</p>

<h2 id="protecting-women-only-spaces">“protecting women-only spaces”</h2>

<p>This is an incredibly scary TERF dog-whistle. At the present, the equality act (which also applies in Scotland, not just England) allows discrimination against trans folks in some cases:</p>

<blockquote>
  <p>a service provider provides single-sex services. If you are accessing a service provided for men-only or women-only, the organisation providing it should treat you according to your acquired gender. In very restricted circumstances it is lawful for an organisation to provide a different service or to refuse the service to someone who is undergoing or has undergone gender reassignment</p>

  <p><a href="https://www.scottishtrans.org/trans-rights/principles/equality-act-2010/">Scottish Trans Alliance</a></p>
</blockquote>

<p>The issue here is that the definition of what services <em>can</em> legally refuse access to trans people is vague, and could be re-defined to include bathrooms, which the tories seem intent on doing. Make no mistake, that would be just as bad as the “Bathroom Bills” that flourished in the US a few years back. If you thought “oh well we’re better than Georgia” 1) clearly, we’re not and 2) you’re gonna have to fight with us.</p>

<p>Not only are those laws un-enforceable (what are we gonna do? Check everyone’s genitals when they come in?), they are highly misogynistic. While TERFs love to claim that cis women are at risk from trans women using the same bathrooms, there have been multiple occurrences of cis butch women being harassed by TERFs because they were sure they were trans and tried to chase them (<a href="https://www.vox.com/2016/5/18/11690234/women-bathrooms-harassment">Vox/German Lopez</a>).</p>

<p>There has been, at least, one instance of a TERF bragging about trying to get an up-skirt photo of someone they believed to be a trans woman. If this become law, cis women and trans people alike will be more at risk. Trans and non-binary folks by the humiliation of having to use bathrooms they know full well are not for them, cis women by the self righteous TERFs who will try and shame anyone who doesn’t “look like a woman” out of bathrooms.</p>

<h2 id="cracking-down-on-quack-doctors">“Cracking down on quack doctors”</h2>

<p>…who apparently hand out medical opinions left right and centre. These do not exist. Getting any kind of access to transgender healthcare in this country is a matter of years. It took me 12 months to get an appointment at the Sandyford GIC (Gender Identity Clinic). This was two years ago, and the waiting list is now up to 24 months. Down in England, some of the GICs are now approaching 4 years between referral and first appointment.</p>

<p>You don’t get support - <em>any</em> support - until you’ve been “diagnosed”. I’d like to be clear: <strong>these waiting times kill people</strong>. The only way most people get access to hormone treatment in less than years is by going through private services. These are ran by doctors who, I would bet my life on that, know more about caring for trans folks than some of the “experts” I’ve had appointments with at NHS services.</p>

<p>If these people are who the article refers to as “quack doctors”, they’re preparing to kill trans people, simple as that. <a href="https://www.stonewall.org.uk/sites/default/files/trans_stats.pdf">More than 50% (Stonewall)</a> of trans people have not only thought about, but attempted self harm and suicide. Studies show that providing gender-affirming hormone treatment improves those statistics. Stripping away the one avenue people have to speed up transition is criminal.</p>

<h2 id="restricting-access-to-healthcare-for-trans-youth">Restricting access to healthcare for trans youth</h2>

<p>The article also refers to Liz Truss “strengthening advice on medical procedures on under-18s that have irreversible effects on their fertility”. This is once again a TERF dog-whistle. There are no such procedures being done in the UK at the moment, and no-one is advocating for that.</p>

<p>The best you can get as a trans or questioning teen is hormone blockers – these will delay puberty, the idea being that you can avoid going through a puberty that doesn’t match your gender, and re-evaluate at 16. <strong>This is not irreversible</strong>. If at 16 you realise that you aren’t trans, you can stop taking blockers and experience a normal, albeit slightly delayed puberty. Otherwise, you can be moved to gender-affirming hormone treatment and not require a lot of the painful and distressing process of undoing a puberty that wasn’t yours.</p>

<p>Denying trans youth access to blockers is dangerous. The only thing that achieves is destroying the mental health of a minority that’s already struggling.</p>

<h2 id="what-you-can-do">What you can do:</h2>

<ul>
  <li><a href="https://email.number10.gov.uk/">email no 10</a> and express your disagreement with the proposed transphobic laws.</li>
  <li><a href="https://www.writetothem.com/">email your MP</a> – and your MSP if you live in Scotland – to ask what they plan to do to support trans rights and oppose the reform.</li>
  <li>If you leave in Scotland, email the <a href="https://firstminister.gov.scot/join/first-minister-postbag/">First Minister</a> and ask her how she plans to support trans rights in Scotland.</li>
</ul>

<p>and <strong>Donate to organisations that support trans rights, especially black trans voices who are most vulnerable, and read up on trans rights:</strong></p>

<ul>
  <li>Donate to <a href="http://genderedintelligence.co.uk/support-us/donate">Gendered Intelligence</a>. Read their <a href="http://genderedintelligence.co.uk/campaigns/baeb">Body Autonomy for Every Body</a> manifesto;</li>
  <li>Donate to the <a href="https://www.artsbusinesscollaborative.org/asp-products/black-trans-protestors-emergency-fund/">Black Trans Protestors Emergency Fund</a>;</li>
  <li>Donate to the <a href="https://www.artsbusinesscollaborative.org/asp-products/black-trans-femmes-in-the-arts-sponsored-projected_/">Black Trans Femmes in the Arts</a> supports;</li>
  <li>Donate to <a href="https://mermaidsuk.org.uk/">Mermaids</a> (supports Trans Youth &amp; their families);</li>
</ul>

<p><strong>Amplify trans voices, especially from black and indigenous trans communities. Listen. Speak up when you see transphobia.</strong></p>]]></content><author><name>Amy Parent</name></author><category term="lgbt+" /><summary type="html"><![CDATA[Do I have the spoons to do this? Nope. Am I still going to because everyone needs to be fighting this? yup. TL;DR: The UK tory government is planning a large-scale rollback of trans rights, including potential “bathroom bills”, on top of scrapping the much-needed reform to the Gender Recognition Act. If you are cis, your voice is more likely to be heard than ours. You can: email no 10 and express your disagreement with the proposed transphobic laws. email your MP – and your MSP if you live in Scotland – to ask what they plan to do to support trans rights and oppose the reform. If you leave in Scotland, email the First Minister and ask her how she plans to support trans rights in Scotland. and Donate to organisations that support trans rights, especially black trans voices who are most vulnerable, and read up on trans rights: Donate to Gendered Intelligence. Read their Body Autonomy for Every Body manifesto; Donate to the Black Trans Protestors Emergency Fund; Donate to the Black Trans Femmes in the Arts supports; Donate to Mermaids (supports Trans Youth &amp; their families); Amplify trans voices, especially from black and indigenous trans communities. Listen. Speak up when you see transphobia.]]></summary></entry><entry><title type="html">Functions, Overloading, and Nesting, Oh My!</title><link href="https://amyparent.com/blog/orbitvm-diary-8.html" rel="alternate" type="text/html" title="Functions, Overloading, and Nesting, Oh My!" /><published>2020-03-09T11:30:00+00:00</published><updated>2020-03-09T11:30:00+00:00</updated><id>https://amyparent.com/blog/orbitvm-diary-8</id><content type="html" xml:base="https://amyparent.com/blog/orbitvm-diary-8.html"><![CDATA[<p>I’ve started working on Orbit again. Over the last year or so, slowly, I’ve re-written most of the runtime. Nothing major changed, and yet everything has changed a bit. I’ve also finally made progress on <a href="https://github.com/amyinorbit/orbitvm/tree/f03b3f45c697ada977b1c7be2ccc82cfee33e773/libs/sema">semantic analysis</a> and <a href="https://github.com/amyinorbit/orbitvm/tree/f03b3f45c697ada977b1c7be2ccc82cfee33e773/libs/codegen">code generation</a>, to the point that orbit now has a (small, and simple) REPL! It can parse, check, and run simple expressions as well as conditional logic (<code class="language-plaintext highlighter-rouge">if</code>/<code class="language-plaintext highlighter-rouge">else</code>/<code class="language-plaintext highlighter-rouge">while</code>, <code class="language-plaintext highlighter-rouge">for ... in</code> will come later).</p>

<p><img src="/static/media/2020/0300-orbit.gif" alt="GIF demo of Orbit's REPL" class="tiny" /></p>

<p>Now that the basics are working, the main thing missing from the language before it can be used for writing small scripts (aside from any kind of standard library) are functions. I’ve talked a lot about the fine details of functions invocation, but what I’ve realised over the past couple of weeks trying to implement the code-generation side of things is that I don’t have a clear idea of the <em>semantics</em> of Orbit’s functions.</p>

<h2 id="first-class">First Class</h2>

<p>One thing I know for sure is that I want functions to be first-class in orbit. If you want to store a reference to a function and invoke that later, you should be able to. A function declaration should essentially be a literal, which tells the compiler about a bit of data (in this case, bytecode).
s is reflected by a slight change I’ve made to the syntax. Until then, a function was declared like that:</p>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">fun</span> <span class="n">sayHello</span><span class="p">(</span><span class="n">name</span><span class="o">:</span> <span class="n">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Void</span> <span class="p">{</span>
    <span class="n">print</span><span class="p">(</span><span class="s">"Hello, "</span> <span class="o">+</span> <span class="n">name</span> <span class="o">+</span> <span class="s">"!"</span><span class="p">)</span>
<span class="p">}</span>
</code></pre></div></div>

<p>In the current version of Orbit, the syntax is more in-line with the variable declaration syntax:</p>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">fun</span> <span class="n">sayHello</span> <span class="o">=</span> <span class="p">(</span><span class="n">name</span><span class="o">:</span> <span class="n">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Void</span> <span class="p">{</span>
    <span class="n">print</span><span class="p">(</span><span class="s">"Hello, "</span> <span class="o">+</span> <span class="n">name</span> <span class="o">+</span> <span class="s">"!"</span><span class="p">)</span>
<span class="p">}</span>
</code></pre></div></div>

<p>It’s mostly an aesthetic change, but I want the syntax to reflect the semantics. I also made it so that nested functions can be parsed. If functions are treated just like any other bit of data, it makes sense that you could declare one in a limited scope. In theory, that’s all fine and dandy, but no plan survives contact with the enemy. Which brings me to…</p>

<h2 id="overloading">Overloading</h2>

<p>I really, really want overloading in orbit. I think it’s one of those “small” features that go a long way to making a language friendlier to use. I want this to compile and run properly:</p>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">fun</span> <span class="nf">test</span><span class="p">(</span><span class="n">value</span><span class="o">:</span> <span class="n">Int</span><span class="p">)</span> <span class="p">{}</span> <span class="c1">// (1)</span>
<span class="n">fun</span> <span class="nf">test</span><span class="p">(</span><span class="n">value</span><span class="o">:</span> <span class="n">String</span><span class="p">)</span> <span class="p">{}</span> <span class="c1">// (2)</span>

<span class="n">test</span><span class="p">(</span><span class="mi">123</span><span class="p">)</span> <span class="c1">// calls (1)</span>
<span class="n">test</span><span class="p">(</span><span class="s">"Hello!"</span><span class="p">)</span> <span class="c1">// calls (2)</span>
</code></pre></div></div>

<p>The way I was going to handle this is using a function table tweaked so that lookup cares not only about the name of the function being invoked, but also its parameter list. When seeing something like <code class="language-plaintext highlighter-rouge">test("hello")</code>, the semantic analyser would go through the table and only compile if it found a function declared as <code class="language-plaintext highlighter-rouge">test(_: String)</code>.
Behind the scenes, this means we can have multiple functions declared with the same name, which does not gel too well. We solve this with name mangling: the <em>actual</em> name of the function is doctored by the compiler to include data about the parameters and return type. <code class="language-plaintext highlighter-rouge">test(_:String) -&gt; Void</code> is actually called <code class="language-plaintext highlighter-rouge">_OF4testpNsev</code> (the grammar for this is <a href="https://github.com/amyinorbit/orbitvm/blob/f03b3f45c697ada977b1c7be2ccc82cfee33e773/specs/name-mangling.md">defined on GitHub</a> too). So far, so good.</p>

<p>Except we are not quite out of the woods. Let’s say we have this:</p>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">fun</span> <span class="nf">test</span><span class="p">(</span><span class="n">value</span><span class="o">:</span> <span class="n">Int</span><span class="p">)</span> <span class="p">{}</span> <span class="c1">// (1)</span>
<span class="n">fun</span> <span class="nf">test</span><span class="p">(</span><span class="n">value</span><span class="o">:</span> <span class="n">String</span><span class="p">)</span> <span class="p">{}</span> <span class="c1">// (2)</span>

<span class="n">fun</span> <span class="n">main</span> <span class="o">=</span> <span class="p">{</span>
    <span class="n">var</span> <span class="n">captured</span> <span class="o">=</span> <span class="n">test</span>
    <span class="n">captured</span><span class="p">(</span><span class="mi">123</span><span class="p">)</span>
<span class="p">}</span>
</code></pre></div></div>

<p>In this case, <code class="language-plaintext highlighter-rouge">captured</code> is a local variable and contains a reference to… what? The compiler cannot tell, when it’s compiled the declaration, which version of <code class="language-plaintext highlighter-rouge">test()</code> we intend to store. There are two solutions to this: we could forbid storing overloaded functions in variables (easy), or provide a way to tell the compiler which function we want to capture, for example <code class="language-plaintext highlighter-rouge">var captured = test(Int)</code> (not as easy, but doable). One problem solved.</p>

<p>But there’s more. When the compiler (in its current state) sees the call to <code class="language-plaintext highlighter-rouge">captured(123)</code>, it is going to go look in the module/file’s function table, and then throw an error because it cannot find a function called <code class="language-plaintext highlighter-rouge">captured</code> in there. Technically, this is right. One way to solve this is to delay throwing the error:</p>

<ol>
  <li>Do a lookup in the scope stack for a variable called <code class="language-plaintext highlighter-rouge">captured</code>.
    <ul>
      <li>If no variable is found, go to 2.</li>
      <li>If the variable is not callable with arguments of type <code class="language-plaintext highlighter-rouge">(Int)</code>, throw an error.</li>
      <li>Otherwise, resolve the call and emit bytecode.</li>
    </ul>
  </li>
  <li>Do a lookup in the module’s function table for <code class="language-plaintext highlighter-rouge">captured(Int)</code>.
    <ul>
      <li>If no function matches, throw an error.</li>
      <li>Otherwise, resolve the call and emit bytecode.</li>
    </ul>
  </li>
</ol>

<p>The last problem with that method (it never ends!) is overloading. What happens in this case?</p>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">fun</span> <span class="nf">test</span><span class="p">(</span><span class="n">value</span><span class="o">:</span> <span class="n">Int</span><span class="p">)</span> <span class="p">{}</span> <span class="c1">// (1)</span>
<span class="n">fun</span> <span class="nf">test</span><span class="p">(</span><span class="n">value</span><span class="o">:</span> <span class="n">String</span><span class="p">)</span> <span class="p">{}</span> <span class="c1">// (2)</span>

<span class="n">fun</span> <span class="n">main</span> <span class="o">=</span> <span class="p">{</span>
    <span class="n">fun</span> <span class="n">test</span><span class="p">(</span><span class="n">value</span><span class="o">:</span> <span class="n">Float</span><span class="p">)</span> <span class="p">{}</span>
    <span class="n">test</span><span class="p">(</span><span class="s">"Hello"</span><span class="p">)</span><span class="err">`</span><span class="p">,</span>
<span class="p">}</span>
</code></pre></div></div>

<p>Sema is going to find a variable called <code class="language-plaintext highlighter-rouge">test</code>, and throw an error because the nested function is not callable with an argument list of <code class="language-plaintext highlighter-rouge">(String)</code> – even though there is an overload that exists in the function table. I’m not 100% sure how (or really, if) I want to solve this. It might just be a case that only module-level functions can be overloaded. After all, that’s what Swift does, and that’s good enough for me!</p>]]></content><author><name>Amy Parent</name></author><category term="language," /><category term="programming" /><summary type="html"><![CDATA[I’ve started working on Orbit again. Over the last year or so, slowly, I’ve re-written most of the runtime. Nothing major changed, and yet everything has changed a bit. I’ve also finally made progress on semantic analysis and code generation, to the point that orbit now has a (small, and simple) REPL! It can parse, check, and run simple expressions as well as conditional logic (if/else/while, for ... in will come later). Now that the basics are working, the main thing missing from the language before it can be used for writing small scripts (aside from any kind of standard library) are functions. I’ve talked a lot about the fine details of functions invocation, but what I’ve realised over the past couple of weeks trying to implement the code-generation side of things is that I don’t have a clear idea of the semantics of Orbit’s functions. First Class One thing I know for sure is that I want functions to be first-class in orbit. If you want to store a reference to a function and invoke that later, you should be able to. A function declaration should essentially be a literal, which tells the compiler about a bit of data (in this case, bytecode). s is reflected by a slight change I’ve made to the syntax. Until then, a function was declared like that: fun sayHello(name: String) -&gt; Void { print("Hello, " + name + "!") } In the current version of Orbit, the syntax is more in-line with the variable declaration syntax: fun sayHello = (name: String) -&gt; Void { print("Hello, " + name + "!") } It’s mostly an aesthetic change, but I want the syntax to reflect the semantics. I also made it so that nested functions can be parsed. If functions are treated just like any other bit of data, it makes sense that you could declare one in a limited scope. In theory, that’s all fine and dandy, but no plan survives contact with the enemy. Which brings me to… Overloading I really, really want overloading in orbit. I think it’s one of those “small” features that go a long way to making a language friendlier to use. I want this to compile and run properly: fun test(value: Int) {} // (1) fun test(value: String) {} // (2) test(123) // calls (1) test("Hello!") // calls (2) The way I was going to handle this is using a function table tweaked so that lookup cares not only about the name of the function being invoked, but also its parameter list. When seeing something like test("hello"), the semantic analyser would go through the table and only compile if it found a function declared as test(_: String). Behind the scenes, this means we can have multiple functions declared with the same name, which does not gel too well. We solve this with name mangling: the actual name of the function is doctored by the compiler to include data about the parameters and return type. test(_:String) -&gt; Void is actually called _OF4testpNsev (the grammar for this is defined on GitHub too). So far, so good. Except we are not quite out of the woods. Let’s say we have this: fun test(value: Int) {} // (1) fun test(value: String) {} // (2) fun main = { var captured = test captured(123) } In this case, captured is a local variable and contains a reference to… what? The compiler cannot tell, when it’s compiled the declaration, which version of test() we intend to store. There are two solutions to this: we could forbid storing overloaded functions in variables (easy), or provide a way to tell the compiler which function we want to capture, for example var captured = test(Int) (not as easy, but doable). One problem solved. But there’s more. When the compiler (in its current state) sees the call to captured(123), it is going to go look in the module/file’s function table, and then throw an error because it cannot find a function called captured in there. Technically, this is right. One way to solve this is to delay throwing the error: Do a lookup in the scope stack for a variable called captured. If no variable is found, go to 2. If the variable is not callable with arguments of type (Int), throw an error. Otherwise, resolve the call and emit bytecode. Do a lookup in the module’s function table for captured(Int). If no function matches, throw an error. Otherwise, resolve the call and emit bytecode. The last problem with that method (it never ends!) is overloading. What happens in this case? fun test(value: Int) {} // (1) fun test(value: String) {} // (2) fun main = { fun test(value: Float) {} test("Hello")`, } Sema is going to find a variable called test, and throw an error because the nested function is not callable with an argument list of (String) – even though there is an overload that exists in the function table. I’m not 100% sure how (or really, if) I want to solve this. It might just be a case that only module-level functions can be overloaded. After all, that’s what Swift does, and that’s good enough for me!]]></summary></entry><entry><title type="html">Secret Life Awesome Plan</title><link href="https://amyparent.com/blog/life-plan.html" rel="alternate" type="text/html" title="Secret Life Awesome Plan" /><published>2019-09-04T00:00:00+01:00</published><updated>2019-09-04T00:00:00+01:00</updated><id>https://amyparent.com/blog/life-plan</id><content type="html" xml:base="https://amyparent.com/blog/life-plan.html"><![CDATA[<p>SLAP. Because this plan SLAPs. Or <em>26 is as good a time as any to have a quarter-life crisis and rethink my priorities I guess?</em></p>

<p><strong>Short(ish) term</strong></p>

<ul>
  <li>Apply and (fingers crossed) obtain EU settled status in the UK</li>
  <li>Finish that darn PhD (with which I have a love-hate-hate relationship)</li>
  <li>Learn to love roller derby again</li>
  <li>Go see Garbage live (hey, small victories)</li>
  <li>Start writing again. Fiction, non-fiction, here.</li>
</ul>

<p><strong>Medium term</strong></p>

<ul>
  <li>Find a job (or postdoc, maybe?) hopefully programming or in aerospace</li>
  <li>Move to Glasgow (for the queer community and the general atmosphere)</li>
  <li>Find a place I actually love and make it mine (all the plants 🌱)</li>
  <li>Start saving (never too late to start right?)</li>
</ul>

<p><strong>Long term</strong></p>

<ul>
  <li>Get Scottish citizenship (within or out of the UK)</li>
  <li>Open a cute, queer coffee shop/snack place/workspace. Run it. (code/do research in my spare time)</li>
  <li>Buy (?) my own place.</li>
  <li>Skate for Team Scotland Roller Derby (I never said it had to be realistic)</li>
  <li>Adopt or foster</li>
</ul>

<p>It’s a bit strange how sudden but also how right this felt when it popped in my head and I decided to write it down. If you’d asked me a year ago I’d have never <em>ever</em> thought space or programming wouldn’t be my long term career goal, but this feels so much more <em>right</em>. So much more me. Not that I’ll ever stop writing code, making games and hopefully research space on my spare time. But the idea of running a queer place that I can be proud of makes me dream 1,000% more than writing code for a boss my entire life.</p>]]></content><author><name>Amy Parent</name></author><category term="personal" /><summary type="html"><![CDATA[SLAP. Because this plan SLAPs. Or 26 is as good a time as any to have a quarter-life crisis and rethink my priorities I guess? Short(ish) term Apply and (fingers crossed) obtain EU settled status in the UK Finish that darn PhD (with which I have a love-hate-hate relationship) Learn to love roller derby again Go see Garbage live (hey, small victories) Start writing again. Fiction, non-fiction, here. Medium term Find a job (or postdoc, maybe?) hopefully programming or in aerospace Move to Glasgow (for the queer community and the general atmosphere) Find a place I actually love and make it mine (all the plants 🌱) Start saving (never too late to start right?) Long term Get Scottish citizenship (within or out of the UK) Open a cute, queer coffee shop/snack place/workspace. Run it. (code/do research in my spare time) Buy (?) my own place. Skate for Team Scotland Roller Derby (I never said it had to be realistic) Adopt or foster It’s a bit strange how sudden but also how right this felt when it popped in my head and I decided to write it down. If you’d asked me a year ago I’d have never ever thought space or programming wouldn’t be my long term career goal, but this feels so much more right. So much more me. Not that I’ll ever stop writing code, making games and hopefully research space on my spare time. But the idea of running a queer place that I can be proud of makes me dream 1,000% more than writing code for a boss my entire life.]]></summary></entry><entry><title type="html">Simulating Spacecraft Reentry</title><link href="https://amyparent.com/blog/crew-dragon-reentry.html" rel="alternate" type="text/html" title="Simulating Spacecraft Reentry" /><published>2019-03-07T00:00:00+00:00</published><updated>2019-03-07T00:00:00+00:00</updated><id>https://amyparent.com/blog/crew-dragon-reentry</id><content type="html" xml:base="https://amyparent.com/blog/crew-dragon-reentry.html"><![CDATA[<p>After years of development, the first Crew Dragon <a href="https://www.theverge.com/2019/3/3/18244501/spacex-crew-dragon-automatic-docking-international-space-station-nasa">reached the International Space Station</a> on Sunday (this spacecraft is gorgeous!) and is <a href="https://www.theverge.com/2019/3/7/18254549/spacex-crew-dragon-iss-nasa-landing-parachutes-splashdown">coming back</a> to land tomorrow, off the coast of Florida. Discussing the reentry on twitter with a couple of folks yesterday, I came across an interesting question: do we know how long before splashdown Dragon will fly over which parts of the world?</p>

<p>If you work at SpaceX or NASA, the answer is (I hope) yes. Since I don’t work for either, I spent the evening trying to program a (simplistic) reentry simulation to find out for myself. I’d done that years ago but the physics and code were pretty appalling, so I started from scratch.</p>

<p><img src="/static/media/2019/03/dragon-traj.svg" alt="Crew Dragon Reentry Trajectory" class="small" /></p>

<p>Reentry is a relatively simple problem to solve as long as you don’t look at the details. There are either two or three forces acting on the spacecraft: gravity, aerodynamic drag, and in the case of Dragon – or really most modern spacecrafts since the introduction of Soyuz – lift. There are <a href="https://en.wikipedia.org/wiki/Drag_equation">simplified equations</a> for all of these, which I used to derive equations of motion, coded into a quick-and-dirty Euler solver.</p>

<p>There are <em>major</em> issues with this, obviously. Aerodynamic parameters for a spacecraft are both complex – you go from hypersonic flight in plasma to subsonic flight under parachutes – and not exactly published in great details. The lift and drag equations I use are also not all that good in very-low-density gases, which is where spacecrafts spend a good chunk of their reentries.</p>

<p><img src="/static/media/2019/03/dragon-load_time.svg" alt="Crew Dragon g-load vs time" class="right" /></p>

<p>Still, I came up with some trajectories and g-loads that look pretty close to what you’d expect. Lifting reentries to low earth orbit are usually between 3G and 5G (Trevino 2008), which we have here. We can see an upwards bend in the trajectory when lift starts to be significant, and it takes the capsule about 8 minutes to go from Entry Interface to parachute deployment, which matches the <a href="https://forum.nasaspaceflight.com/index.php?topic=47552.msg1918994#msg1918994">timeline obtained by NASASpaceFlight</a> nicely!</p>

<p><img src="/static/media/2019/03/dragon-dtg.svg" alt="Crew Dragon distance-to-go plot" class="right" /></p>

<p>I also made a plot that shows how far dragon will be from splashdown compared to the time left before it gets there. Bear in mind, the simulation stops when the parachute would open, so it’s not very precise – Dragon will probably drift due to winds – and needs a couple of minutes added onto the timeline to get to the predicted splashdown time.</p>

<h2 id="what-if-we-tried-more-spacecrafts">What if we tried more spacecrafts?</h2>

<p><img src="/static/media/2019/03/mars-entries.png" alt="Mars Entries over time" class="right" /></p>

<p>Since I specialise in taking things too far, I tried to find aerodynamic data for more spacecrafts and planets. It turns out you can find a lot of information on NASA’s Mars missions, so I tried to plot reentries for Pathfinder, Opportunity and Curiosity. The results are surprisingly okay! Not stellar, but also not too far off compared to a plot found in (Edquist et al. 2009), which is more than I expected given the small amount of time I spent working on this!</p>

<p><img src="/static/media/2019/03/mars-vel.svg" alt="Mars spacecrafts' velocity/altitude profiles" class="left" /></p>

<p>Curiosity’s profile is probably the one that’s further off, and it makes sense. Of those three missions, it’s the only one that used body lift to control its entry. In my simulations, that lift is pointed up the whole time, whereas the real mission rolled around to steer and control the descent. As a bonus, I added the now-cancelled Red Dragon’s entry, thought it’s also probably way off. Had it happened, the plan for the mission was to point the lift downwards (!) to reach the thicker layers of the atmosphere, then modulate it to achieve level-ish flight and shed speed there, instead of skipping back up like it does in my sims.</p>

<p><img src="/static/media/2019/03/mars-traj.svg" alt="Mars spacecrafts' Entry trajectories" class="small" /></p>

<hr />

<p>Realistically, these kind of simulations don’t have a lot of value in terms of real-life applications – you won’t design a mission with one single dirty python script. But they’re the kind of things I love spending some time doing once in a while, because they show that first principles are still a good way to get an idea of what a problem looks like. That, and saying that you can (sort of) simulate the next Crew Dragon reentry on your laptop gets you a bunch of cool points 🚶🏻‍♀️🚀</p>

<h2 id="source-code">Source Code</h2>

<p>I coded all of this using Python 3, and Matplotlib for plotting. You can get the source from GitHub at <a href="https://github.com/amyinorbit/reentry.py">amyinorbit/reentry.py</a>. It’s under the MIT license, so feel free to hack it and make changes to it! There’s tonnes that could be done – adding more planets, using a more robust solver, etc.</p>

<h2 id="papers-i-read--used">Papers I read &amp; used</h2>

<ol>
  <li>Trevino, Loretta. <a href="https://smartech.gatech.edu/bitstream/handle/1853/26437/107-277-1-PB.pdf?sequence=1&amp;isAllowed=y"><em>SpaceX Dragon Re-Entry Vehicle: Aerodynamics and Aerothermodynamics with Application to Base Heat-Shield Design</em></a>. Georgia Institute of Technology, 2008.</li>
  <li>Karcz, John, et al. <a href="https://ntrs.nasa.gov/search.jsp?R=20120013431"><em>Red dragon: Low-cost access to the surface of mars using commercial capabilities</em></a>. 2012.</li>
  <li>Edquist, Karl, et al. <a href="https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20090024230.pdf"><em>Aerothermodynamic design of the Mars Science Laboratory heatshield</em></a>. 41st AIAA Thermophysics Conference. 2009.</li>
</ol>]]></content><author><name>Amy Parent</name></author><summary type="html"><![CDATA[After years of development, the first Crew Dragon reached the International Space Station on Sunday (this spacecraft is gorgeous!) and is coming back to land tomorrow, off the coast of Florida. Discussing the reentry on twitter with a couple of folks yesterday, I came across an interesting question: do we know how long before splashdown Dragon will fly over which parts of the world? If you work at SpaceX or NASA, the answer is (I hope) yes. Since I don’t work for either, I spent the evening trying to program a (simplistic) reentry simulation to find out for myself. I’d done that years ago but the physics and code were pretty appalling, so I started from scratch.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://amyparent.com/static/media/2019/03/mars-traj.png" /><media:content medium="image" url="https://amyparent.com/static/media/2019/03/mars-traj.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Transition &amp;amp; Marina</title><link href="https://amyparent.com/blog/transition-marina.html" rel="alternate" type="text/html" title="Transition &amp;amp; Marina" /><published>2019-02-18T13:05:00+00:00</published><updated>2019-02-18T13:05:00+00:00</updated><id>https://amyparent.com/blog/transition-marina</id><content type="html" xml:base="https://amyparent.com/blog/transition-marina.html"><![CDATA[<p><img src="/static/media/2019/02/marina_love_fear.jpg" alt="Marina's Love+Fear album" class="right" /></p>

<p>Transitioning is an altogether weird experience. I’m just over two years in, and there are still things I discover every day. About my body, about the effects hormones have on it – I now have a waist and hips, apparently! – but also about things I realise I was never taught because I wasn’t raised as a girl – the politics of going home alone at night – or the thousands little things that I now know were pretty good signs that I was never a boy.</p>

<p>There’s me wondering at eight why my shoes weren’t making that clacky noise that heels make. Me in high school, feeling excluded when I didn’t have any period stories to complain about with my friends, who were mostly girls. Another one I’ve picked up on recently is Marina (and the Diamonds).</p>

<p>I discovered Marina’s music at a time where I think I was starting to know that I wasn’t a guy (even though I would never had admitted it then). I was around 20, realising how little I fitted with “the guys”. We spent a good deal of time that summer playing just dance at a friend’s, and as far as I can remember it’s the first time I actually let myself dance (very badly) around other people without holding back. The one song that I could vaguely manage was <a href="https://www.youtube.com/watch?v=Cr-SqRWImmI"><em>Oh No!</em></a>, and I fell in love with it.</p>

<p>Back home, I started listening to Marina’s then two albums (<em>Family Jewels</em> and <em>Electra Heart</em>). It was the most stereotypically girly thing I’d done so far, and I must have known because I was almost scared of my family knowing, which seems fairly silly in hindsight unless I really knew what that meant and tried to ignore it.</p>

<p>When <em>FROOT</em> came out, I’d moved to Scotland, and I’d stopped being so secretive about listening to girly things. I waited every month for the next single to drop, and I was up in front of my laptop with my debit card clutched in my hand the second the tickets for the <em>Neon Nature</em> Glasgow dates were available. To date, it’s the best gig I’ve ever been to.</p>

<p>Even though it was a whole year before I finally admitted that I was, in fact, a girl, I think that night was the first time I presented and acted as myself, ever. I got a eyeliner heart drawn on my cheek and screamed, sung and danced with everyone in the pit. I was surrounded with girls and women and felt like I belonged. Looking back, it’s hard to know how much of how good I felt that night was because I got to see my favourite singer on stage, and how much of it was because I got to be myself.</p>

<p><img src="/static/media/2019/02/marina_neon_nature.jpg" alt="Neon Nature Tour concert picture" class="left" /></p>

<p>I’ve always attached a lot of – probably too much – meaning to music. But Marina’s will always be special to me, because it was a way for me to be feminine when even myself wouldn’t have accepted it otherwise. So that’s why I’m incredibly excited to listen to her next album, and so happy that I get to go see her in convert again soon, this time knowing exactly who I am and enjoying every second of it 💎</p>]]></content><author><name>Amy Parent</name></author><summary type="html"><![CDATA[Transitioning is an altogether weird experience. I’m just over two years in, and there are still things I discover every day. About my body, about the effects hormones have on it – I now have a waist and hips, apparently! – but also about things I realise I was never taught because I wasn’t raised as a girl – the politics of going home alone at night – or the thousands little things that I now know were pretty good signs that I was never a boy. There’s me wondering at eight why my shoes weren’t making that clacky noise that heels make. Me in high school, feeling excluded when I didn’t have any period stories to complain about with my friends, who were mostly girls. Another one I’ve picked up on recently is Marina (and the Diamonds).]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://amyparent.com/static/media/2019/02/marina_love_fear.jpg" /><media:content medium="image" url="https://amyparent.com/static/media/2019/02/marina_love_fear.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">PKN Dundee - Transition and Roller Skates</title><link href="https://amyparent.com/blog/pkn22.html" rel="alternate" type="text/html" title="PKN Dundee - Transition and Roller Skates" /><published>2018-11-09T00:00:00+00:00</published><updated>2018-11-09T00:00:00+00:00</updated><id>https://amyparent.com/blog/pkn22</id><content type="html" xml:base="https://amyparent.com/blog/pkn22.html"><![CDATA[<p><img src="/static/media/2018/11/pkn_talking.jpg" alt="Amy parent speaking at PKN22 Dundee" /><br />
<em>Image © Kathrin Rattray/Creative Dundee</em></p>

<p>Last Tuesday, <a href="https://creativedundee.com">Creative Dundee</a> invited me to speak at <a href="https://creativedundee.com/2018/10/pecha-kucha-night-dundee-vol-22/">Pecha Kucha Night volume 22</a>. I decided to talk about my transition, and how learning to play roller derby with the wonderful people from <a href="https://www.facebook.com/dundeerollerderby">DRD</a> has helped me accept myself. The talk felt too personal to use powerpoint (and I didn’t really have the pictures I wanted to illustrate what I was saying) so I drew my slides instead. It was really fun to take a bunch of hours doing nothing but art for once, and I’m really proud of how the slides (and the talk!) turned out.</p>

<p><img src="/static/media/2018/11/pkn_2.png" alt="PKN22, slides 5 to 8" /></p>

<p>I used a mix of physical and digital techniques, which was a first for me: I drew the linearts with pencil and then marker pen on paper, then photographed them, burnt the exposure to make sure the whites were white, and then coloured everything using my old Wacom tablet and Pixelmator Pro. I’ve made a collage of the slides below, you can download the full images <a href="https://amyparent.com/static/files/pkn22.zip">there</a>, and I’ll add the video of the talk once it’s available online</p>

<p><img src="/static/media/2018/11/pkn_1.png" alt="PKN22, slides 1 to 4" /></p>

<p><img src="/static/media/2018/11/pkn_2.png" alt="PKN22, slides 5 to 8" /></p>

<p><img src="/static/media/2018/11/pkn_3.png" alt="PKN22, slides 9 to 12" /></p>

<p><img src="/static/media/2018/11/pkn_4.png" alt="PKN22, slides 13 to 16" /></p>

<p><img src="/static/media/2018/11/pkn_5.png" alt="PKN22, slides 17 to 20" /></p>]]></content><author><name>Amy Parent</name></author><summary type="html"><![CDATA[Image © Kathrin Rattray/Creative Dundee Last Tuesday, Creative Dundee invited me to speak at Pecha Kucha Night volume 22. I decided to talk about my transition, and how learning to play roller derby with the wonderful people from DRD has helped me accept myself. The talk felt too personal to use powerpoint (and I didn’t really have the pictures I wanted to illustrate what I was saying) so I drew my slides instead. It was really fun to take a bunch of hours doing nothing but art for once, and I’m really proud of how the slides (and the talk!) turned out. I used a mix of physical and digital techniques, which was a first for me: I drew the linearts with pencil and then marker pen on paper, then photographed them, burnt the exposure to make sure the whites were white, and then coloured everything using my old Wacom tablet and Pixelmator Pro. I’ve made a collage of the slides below, you can download the full images there, and I’ll add the video of the talk once it’s available online]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://amyparent.com/static/media/2018/11/pkn_2.png" /><media:content medium="image" url="https://amyparent.com/static/media/2018/11/pkn_2.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">To Abertay University</title><link href="https://amyparent.com/blog/abertay-waiton-transphobia.html" rel="alternate" type="text/html" title="To Abertay University" /><published>2018-10-02T00:00:00+01:00</published><updated>2018-10-02T00:00:00+01:00</updated><id>https://amyparent.com/blog/abertay-waiton-transphobia</id><content type="html" xml:base="https://amyparent.com/blog/abertay-waiton-transphobia.html"><![CDATA[<p>A few days ago, Dr. Waiton, lecturer at <a href="https://www.abertay.ac.uk">Abertay University</a>, published a vile transphobic opinion piece in The Herald Scotland. Abertay’s support was an important part of my early transition, and this goes against the university’s stance of acceptance of LGBT+ students and staff. Here’s the comments I’ve sent as a complaint to the university. If you are in any way touched by this issue, please send your comments as well to the <a href="https://www.abertaysa.com">Abertay SA</a>, and take the time to sign the <a href="https://www.change.org/p/implement-a-zero-tolerance-policy-in-response-to-the-transphobic-article-by-stuart-waiton">LGBT+ society’s petition</a> asking the university to put in place a zero-tolerance policy on discriminatory speech.</p>

<p>To Abertay leadership: while you may think a lecturer’s personal “opinion” (hate speech) does not reflect your stance on inclusivity, this will reflect on the university, and this will impact transgender and gender non-conforming students and staff. Please do not let it pass.</p>

<p><strong>warning: this contains references to transphobic comments that might upset you. Please only click through if you feel up to dealing with such language</strong></p>

<blockquote>
  <p>I am a transgender woman working on my PhD at Abertay. I started transitioning when I was finishing my undergraduate degree, and felt comfortable doing so because of Abertay and UADSA’s openly supportive LGBTQ+ policies, as well as the support and help that my lecturers and now supervisors offered (as part of then-AMG, now SDI). I found Dr. Waiton’s article transphobic and distressing, and at odds with the open, supporting environment that Abertay seems to be sporting.</p>

  <p>I am worried about possibly having to interact with Dr. Waiton in the future as part of my academic career at Abertay. Views and articles like these proclaiming that dysphoria is a fad and that transition is the result of wanting to feel part of some online communities are exactly why it took me so long to accept that I was transgender, and why I still struggle with feelings that I am not a woman “enough” today. The current anti-transphobic police Scotland campaign is derided in the article as an attack on “beliefs”, but those beliefs state that I should not be allowed to express myself as a woman.</p>

  <p>Had I had lecturers be openly against transgender rights while I was studying for my BSc, I would have felt considerably worse than I was already feeling because of dysphoria. I would not have felt it was safe for me to come out to my lecturers and transition.</p>
</blockquote>]]></content><author><name>Amy Parent</name></author><summary type="html"><![CDATA[A few days ago, Dr. Waiton, lecturer at Abertay University, published a vile transphobic opinion piece in The Herald Scotland. Abertay’s support was an important part of my early transition, and this goes against the university’s stance of acceptance of LGBT+ students and staff. Here’s the comments I’ve sent as a complaint to the university. If you are in any way touched by this issue, please send your comments as well to the Abertay SA, and take the time to sign the LGBT+ society’s petition asking the university to put in place a zero-tolerance policy on discriminatory speech. To Abertay leadership: while you may think a lecturer’s personal “opinion” (hate speech) does not reflect your stance on inclusivity, this will reflect on the university, and this will impact transgender and gender non-conforming students and staff. Please do not let it pass. warning: this contains references to transphobic comments that might upset you. Please only click through if you feel up to dealing with such language]]></summary></entry><entry><title type="html">Syntax Trees and C</title><link href="https://amyparent.com/blog/orbitvm-diary-7.html" rel="alternate" type="text/html" title="Syntax Trees and C" /><published>2017-09-25T15:45:00+01:00</published><updated>2017-09-25T15:45:00+01:00</updated><id>https://amyparent.com/blog/orbitvm-diary-7</id><content type="html" xml:base="https://amyparent.com/blog/orbitvm-diary-7.html"><![CDATA[<p>So as I mentioned in the <a href="/blog/orbitvm-diary-6.html">last entry</a>, I’m at the stage where the parser for
orbit is working – not complete, but complete enough that it parses a file
properly, and that it provides a good framework to which I can add a feature or
two add whenever I have a few hours available to work on Orbit. That’s pretty
cool in and of itself.</p>

<p>So after the parser comes the semantic analyser, optimiser and code generator.
In the first compiler I wrote (<a href="https://github.com/amyinorbit/palc">palc</a>, for a the Language &amp; Compilers class),
semantic analysis and code generation calls were done inline, in each of the
parser’s recognisers. I considered doing this for Orbit too, because it’s
simple.</p>

<p>The problem with that approach is that it’s not exactly flexible. Since bytecode
is generated as the parser goes down the file, you can’t exactly play with the
bytecode structure, so optimisation goes out of the window. It’s also not
extensible, since everything is called from the parser. So instead, I’m going
to do it using an Abstract Syntax Tree (AST).</p>

<p>The one thing I love about the AST is that It’s a good interchange format.
Instead of having each phase written as one huge block, I can split things into
small passes that do one thing, and one thing only, to the AST. And when all
of those passes have run, the code generator can take the final version of
the tree and output bytecode. Smaller passes please me because that’s easier
to write and easier to test. And since the compiler is written as a group of
libraries, other people could write their own compiler by importing those
libraries, and adding their own passes to the built-in ones. I’m not inventing
anything here obviously: <a href="https://llvm.org">LLVM</a> and the <a href="https://github.com/apple/swift">compilers derived from it</a>
work like that.</p>

<h2 id="writing-an-ast-in-c">Writing an AST in C</h2>

<p>In one word: ouch. So far, C hasn’t been (too) much of a problem, but big data
structures like trees are a pain to implement compared to other languages. The
AST is a collection of nodes, that can be of different sub-types (binary and
unary expressions, struct, variable and function declaration…). When you have
neither classes and inheritance, or even better, strongly typed enums or tagged
unions, it means lot of boilerplate code.</p>

<p>In swift for example, I’d have used enums since each case can carry “attached”
data (seriously, enums in Swift are one of its best features). Bonus point for
the fact that enums are value types, which I tend to prefer when possible.</p>

<figure class="highlight"><pre><code class="language-swift" data-lang="swift"><span class="kd">enum</span> <span class="kt">ASTNode</span> <span class="p">{</span>
    <span class="k">case</span> <span class="nf">binaryExpr</span><span class="p">(</span><span class="nv">operator</span><span class="p">:</span> <span class="kt">Token</span><span class="p">,</span> <span class="nv">lhs</span><span class="p">:</span> <span class="kt">ASTNode</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">ASTNode</span><span class="p">)</span>
    <span class="k">case</span> <span class="nf">unaryExpr</span><span class="p">(</span><span class="nv">operator</span><span class="p">:</span> <span class="kt">Token</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">ASTNode</span><span class="p">)</span>
    <span class="o">...</span>
<span class="p">}</span>

<span class="c1">// Usage:</span>
<span class="k">switch</span> <span class="n">someNode</span> <span class="p">{</span>
<span class="k">case</span> <span class="o">.</span><span class="nf">binaryExpr</span><span class="p">(</span><span class="k">let</span> <span class="nv">token</span><span class="p">,</span> <span class="k">let</span> <span class="nv">lhs</span><span class="p">,</span> <span class="k">let</span> <span class="nv">rhs</span><span class="p">):</span>
    <span class="c1">// Do something with the node and its members</span>
    <span class="k">break</span>
<span class="k">case</span> <span class="o">.</span><span class="nf">unaryExpr</span><span class="p">(</span><span class="k">let</span> <span class="nv">token</span><span class="p">,</span> <span class="k">let</span> <span class="nv">rhs</span><span class="p">):</span>
    <span class="c1">// Do something with the node and its members</span>
    <span class="k">break</span>
<span class="p">}</span></code></pre></figure>

<p>In C++, I’d have had a base <code class="language-plaintext highlighter-rouge">ASTNode</code> class, and then subclasses for each type
(less optimal, but still workable). In C, it’s going to have to be a (big)
tagged union, and every time I find a node, I’ll have to check the tag, then
extract the actual payload:</p>

<figure class="highlight"><pre><code class="language-c" data-lang="c"><span class="k">typedef</span> <span class="k">enum</span> <span class="p">{</span>
    <span class="n">AST_EXPR_BINARY</span><span class="p">,</span>
    <span class="n">AST_EXPR_UNARY</span><span class="p">,</span>
    <span class="p">...</span>
<span class="p">}</span> <span class="n">ASTNodeType</span><span class="p">;</span>

<span class="k">typedef</span> <span class="k">struct</span> <span class="n">_ASTNode</span> <span class="n">ASTNode</span><span class="p">;</span>

<span class="k">struct</span> <span class="n">_ASTNode</span> <span class="p">{</span>
    <span class="n">ASTNodeType</span>         <span class="n">type</span><span class="p">;</span>
    <span class="k">union</span> <span class="p">{</span>
        <span class="k">struct</span> <span class="p">{</span>
            <span class="n">Token</span><span class="o">*</span>      <span class="n">operator</span><span class="p">;</span>
            <span class="n">ASTNode</span><span class="o">*</span>    <span class="n">lhs</span><span class="p">;</span>
            <span class="n">ASTNode</span><span class="o">*</span>    <span class="n">rhs</span><span class="p">;</span>
        <span class="p">}</span> <span class="n">binaryExpr</span><span class="p">;</span>
        
        <span class="k">struct</span> <span class="p">{</span>
            <span class="n">Token</span><span class="o">*</span>      <span class="n">operator</span><span class="p">;</span>
            <span class="n">ASTNode</span><span class="o">*</span>    <span class="n">rhs</span><span class="p">;</span>
        <span class="p">}</span> <span class="n">unaryExpr</span><span class="p">;</span>
        
        <span class="p">...</span>
    <span class="p">}</span> <span class="n">as</span><span class="p">;</span>
<span class="p">};</span>

<span class="c1">// Usage:</span>
<span class="k">switch</span><span class="p">(</span><span class="n">someNode</span><span class="o">-&gt;</span><span class="n">type</span><span class="p">)</span> <span class="p">{</span>
<span class="k">case</span> <span class="n">AST_EXPR_BINARY</span><span class="p">:</span>
    <span class="n">Token</span><span class="o">*</span> <span class="n">operator</span> <span class="o">=</span> <span class="n">someNode</span><span class="o">-&gt;</span><span class="n">as</span><span class="p">.</span><span class="n">binaryExpr</span><span class="p">.</span><span class="n">operator</span><span class="p">;</span>
    <span class="n">ASTNode</span><span class="o">*</span> <span class="n">lhs</span> <span class="o">=</span> <span class="n">someNode</span><span class="o">-&gt;</span><span class="n">as</span><span class="p">.</span><span class="n">binaryExpr</span><span class="p">.</span><span class="n">lhs</span><span class="p">;</span>
    <span class="n">ASTNode</span><span class="o">*</span> <span class="n">rhs</span> <span class="o">=</span> <span class="n">someNode</span><span class="o">-&gt;</span><span class="n">as</span><span class="p">.</span><span class="n">binaryExpr</span><span class="p">.</span><span class="n">rhs</span><span class="p">;</span>
    
    <span class="c1">// Do something with the node and its members</span>
    <span class="k">break</span><span class="p">;</span>

<span class="k">case</span> <span class="n">AST_EXPR_UNARY</span><span class="p">:</span>
    <span class="n">Token</span><span class="o">*</span> <span class="n">operator</span> <span class="o">=</span> <span class="n">someNode</span><span class="o">-&gt;</span><span class="n">as</span><span class="p">.</span><span class="n">binaryExpr</span><span class="p">.</span><span class="n">operator</span><span class="p">;</span>
    <span class="n">ASTNode</span><span class="o">*</span> <span class="n">rhs</span> <span class="o">=</span> <span class="n">someNode</span><span class="o">-&gt;</span><span class="n">as</span><span class="p">.</span><span class="n">binaryExpr</span><span class="p">.</span><span class="n">rhs</span><span class="p">;</span>
    
    <span class="c1">// Do something with the node and its members</span>
    <span class="k">break</span><span class="p">;</span>
<span class="p">}</span></code></pre></figure>

<p>I’ve also considered faking inheritance using a base struct, embedded in each
“Derived” struct, but it doesn’t really have any advantage over the manual
tagged union, and just leads to <em>even more</em> boilerplate code. In the end, I’ll
get all of that to work, but it still got me tempted to switch the whole project
to swift. <em>Just</em> for the enums.</p>]]></content><author><name>Amy Parent</name></author><summary type="html"><![CDATA[So as I mentioned in the last entry, I’m at the stage where the parser for orbit is working – not complete, but complete enough that it parses a file properly, and that it provides a good framework to which I can add a feature or two add whenever I have a few hours available to work on Orbit. That’s pretty cool in and of itself. So after the parser comes the semantic analyser, optimiser and code generator. In the first compiler I wrote (palc, for a the Language &amp; Compilers class), semantic analysis and code generation calls were done inline, in each of the parser’s recognisers. I considered doing this for Orbit too, because it’s simple. The problem with that approach is that it’s not exactly flexible. Since bytecode is generated as the parser goes down the file, you can’t exactly play with the bytecode structure, so optimisation goes out of the window. It’s also not extensible, since everything is called from the parser. So instead, I’m going to do it using an Abstract Syntax Tree (AST).]]></summary></entry></feed>