Daily Note - 2024-12-22
Hey, I'm Hanno! These are my daily notes on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!
This note was published before Crosscut was called Crosscut! If it refers to "Caterpillar", that is the old name, just so you know.
Over the last few days, I've been analyzing an example that combines linear types and effects:
file
"a" write
"b" write
Yesterday, I looked into the Write
effect. Today, I'd like to
take a stab at the second effect this could trigger.
Let's call that one
Error
.
If an I/O error happens while writing to a file, then
the code doing the writing could handle the Error
effect and react appropriately. If it
doesn't handle the Error
effect, and some
caller up the chain (maybe the host) does, I think it's
safe to assume that this caller shouldn't resume the
code triggering the effect.
That means we need to take care of file
, by
putting it into the error (as a payload), so whoever
handles that can take care of disposing or re-using it.
write
, which gets control over file
anyway, could take care of that under the
hood. So it wouldn't be a problem in this case. But it
would be a problem, if there are other linear types in
scope, that are unrelated to this error.