logoalt Hacker News

rienbdjtoday at 7:04 AM2 repliesview on HN

Under this strict definition you can’t even throw exceptions!


Replies

mattalextoday at 7:10 AM

Of course you can: you just have to define it in your type. The output set becomes a union type of the normal output and whatever you want as an exception.

If you write this as a monad, your get very similar syntax to procedural code.

show 1 reply
mrkeentoday at 7:52 AM

Then allow partial functions too. Maybe even require them to be tagged as such. (Is that within the capabilities of Zig's programmable type system?)

I don't mind escape hatches - as long as they're visible/greppable in the source code. You can always write undefined/error/panic/trace directives while you're coding, then come back and remove them later.

show 1 reply