Follow

Philosophical coding question. In (as with other -based languages) it's common for procedures to return (false) to indicate failure. So the following one-liner is occasionally useful for simplifying code that deals with the output of such procedures:

(define (opt-map proc arg [default ])
(if arg (proc arg) default))

But as written, this still returns , rather than the given default, if arg is not but (proc arg) is. The question is, is this a good or a bad thing?

I think the real answer is "returning on error is and always has been a hack, compared to using a proper optional type"

Sign in to participate in the conversation
Mastodon @ SDF

"I appreciate SDF but it's a general-purpose server and the name doesn't make it obvious that it's about art." - Eugen Rochko