logoalt Hacker News

SPascareli13today at 6:29 PM2 repliesview on HN

I never fully understood how to work with this "reserved" values being valid instead of errors when you can't allocate more memory, in either case you still need to check if you have a real entity or a reserved/error, right? Does it really make things simpler?


Replies

AlotOfReadingtoday at 6:36 PM

It helps avoid the happy path effect. You're always handling something and there's no hidden control flow from the program runtime creeping in because of the cases you missed.

Tcepsatoday at 6:35 PM

In the reserved case you do still need to check if you have a reserved entity, but you can put it (along with the other allowed "pseudotypes") in a switch/case block and have it just break back out immediately (the no-op mentioned in the article) rather than having to use a separate if/else to check for Null, or clutter things up with a try/catch wrapper.

Does that address what you're asking about?

show 2 replies