<div dir="ltr">I'm reading <a href="https://www.dcc.fc.up.pt/~pbv/aulas/linguagens/peytonjones92implementing.pdf" target="_blank">the original STG paper</a> and implementing it along the way. (Raw link to paper:  <a href="https://www.dcc.fc.up.pt/~pbv/aulas/linguagens/peytonjones92implementing.pdf" target="_blank">https://www.dcc.fc.up.pt/~pbv/aulas/linguagens/peytonjones92implementing.pdf</a>)<div><div>I'm not able to figure out how to invoke <font face="monospace">rule 17 </font>at all. This rule is to update a function call which calls another function. I've tried creating examples, but all of them wind up invoking the constructor update rule.<div><div><br></div><div><div><font face="monospace" size="4">╰─$ cat stg-programs/updatable-fn-calls.stg</font></div><div><font face="monospace" size="4">define nu = {} \n {x, y, w, z} -> x {};</font></div><div><font face="monospace" size="4">define main = {} \n {} -> let</font></div><div><font face="monospace" size="4">                            x = {} \n {} -> One {};</font></div><div><font face="monospace" size="4">                            y = {} \n {} -> Two {};</font></div><div><font face="monospace" size="4">                            // closure to update</font></div><div><font face="monospace" size="4">                            update = {x, y} \u {} -> nu {x, y, y, y};</font></div><div><font face="monospace" size="4">                            // have something in argument stack</font></div><div><font face="monospace" size="4">                            kickstart = {update} \n {a, b} -> update {};</font></div><div><font face="monospace" size="4">                            // make sure this is never evaluated</font></div><div><font face="monospace" size="4">                            bottom = {} \n {} -> bottom {}</font></div><div><font face="monospace" size="4">                         in case (kickstart {bottom, bottom}) of</font></div><div><font face="monospace" size="4">                                 One {} -> Done {};</font></div></div><div><font face="monospace" size="4"><br></font></div><div>This was a program I tried, hoping that the "kickstart" function would ensure that there is something on the argument stack, so that when "nu" is entered, the rule would trigger. However, in my toy STG implementation here <a href="https://github.com/bollu/simplexhc" target="_blank">(simplexhc link)</a> (Raw: <a href="https://github.com/bollu/simplexhc" target="_blank">https://github.com/bollu/simplexhc</a>), the rule is not triggered. You can run it with:</div><div><font face="monospace" size="4">$ stack build && stack exec simplexhc -- stg-programs/updatable-fn-calls.stg</font></div><div><font face="monospace" size="4"><br></font></div><div>I believe I have either misunderstood the rule or mis-implemented it. So if someone could point me to a reference of how to trigger the rule, I'd be very thankful.</div></div></div></div><div>I'd like to have some intuition on the rule and "why it works".</div><div><br></div><div>Cheers,</div><div>~ Siddharth</div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr">Sending this from my phone, please excuse any typos!</div></div>