writing this in C should at least prepare me for modelling ownership in rust correctly
-
-
Replying to @mountain_ghosts
i.e. at least means I've thought through stuff like "who owns this reference and should be responsible for freeing it"
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts
especially stuff like "I need this data because I'm hand it to the client and yield control, which might not be returned"
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts
so, the Parser hands a struct off to an Observer, which copies various things into local vars then sends all those to ruby code
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts
the Parser nulls its pointer before passing over to the Observer, which then frees the struct after copying data but *before* yielding
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts
oh and local allocations are freed before yielding -- they've been copied into ruby strings by then
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts
the Parser can't pass things off to Observer *and then* clean up -- that code might not be reached
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts
you run the risk of leaking memory, or keeping a pointer that's been freed and so writing to it or freeing it later
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts
so figuring out who "owns" what and what state everything is in *before* yielding to user code is crucial and easily broken
2 replies 0 retweets 1 like -
Replying to @mountain_ghosts
the first thing you learn when writing rust is how less rigorous you were than you thought.
2 replies 0 retweets 3 likes
the first few weeks are being convinced the compiler is wrong and then realizing it's not.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.