[HN Gopher] Run Functions in Another Stack with Zig
       ___________________________________________________________________
        
       Run Functions in Another Stack with Zig
        
       Author : Teiolass
       Score  : 10 points
       Date   : 2024-07-11 19:50 UTC (5 days ago)
        
 (HTM) web link (teiolass.gitlab.io)
 (TXT) w3m dump (teiolass.gitlab.io)
        
       | Teiolass wrote:
       | Every program compiled with a reasonable compiler runs putting
       | some of its data in the so called stack. It's fairly easy: when
       | you call a function, the function puts its data on top of the
       | stack; when the function returns the data is removed so that the
       | stacks now exposes the data of the caller function. In this post
       | we mess with this mechanism, but substituting the default area of
       | memory for the stack with a freshly allocated one.
        
       | 8474_s wrote:
       | Why not bypass this nasty stack juggling and just use a
       | async/await?
        
         | Teiolass wrote:
         | Mostly because I just wanted to understand a bit more how these
         | things work. Using abstraction in the form of magic keywords
         | gets the job done (sometimes, but not always) but is almost
         | useless for your understanding.
         | 
         | And I think that the understanding can be very useful even when
         | you use the magic words.
        
       | AndyKelley wrote:
       | Fun fact: zig used to have a `@newStackCall` builtin [1], removed
       | from the language in 0.6.0 [2].
       | 
       | [1]: https://ziglang.org/documentation/0.5.0/#newStackCall
       | 
       | [2]: https://ziglang.org/download/0.6.0/release-
       | notes.html#newSta...
        
       ___________________________________________________________________
       (page generated 2024-07-16 23:00 UTC)