logoalt Hacker News

ndrtoday at 3:14 PM5 repliesview on HN

Is it only me or this sounds a bit counter to clojure philosophy?


Replies

summarybottoday at 3:56 PM

As a Clojurist the standard pattern for ensuring keys-are-set before doing-something is not-as-elegant-as-this. Clojure is full of macros that do useful things :) Simplifying oft-used patterns into compact representations is very on-brand. Plus, you need this like, all the time.

This will eliminate two whole classes of errors: 1) where keys are supplied a value at an undesired nesting-level. 2) where keys are not-yet-set for some other reason.

For the many programmers who have to write in checks and verifications themselves for this, this saves quite a bit of time, removing the interruption from coding and restoring the flow of getting logic-to-symbol.

radstoday at 3:29 PM

The maps are still open to new keys even if some keys are checked. I think that fits in with how clojure.spec and Malli work already, but in a lighter syntax.

show 1 reply
embedding-shapetoday at 4:10 PM

Seems additive to me; no breaking changes, and better control and error messages when opting in for it, seems entirely Clojurely to me.

erichoceantoday at 3:21 PM

It's 100% opt-in at the call site and doesn't affect existing code, so no?

Many people (including myself) already have checked key variants for maps; this mainly extends the syntax to destructuring too.

bcrosby95today at 4:27 PM

Howso?