Fork me on GitHub

Once in a while I'm toying with Clojure, currently I'm trying to learn how to benefit from specs. I just re-watched Hickey's "Maybe Not" talk to support some thoughts running through my head. I ended up wondering about a thing in the proposed schema solution: In the selection we give ::user [::first ::last] etc. Now what's the point of ::user? Why not just {::first ::last}? Just for communication? I'm not sure of the value it adds to communication. One thought I had was that it's there to tell us that we might be using other stuff from the ::user too, like ::addr, we just don't require it. But isn't this then just a briefer, less informative way of saying {:req [::first ::last] :opt [::addr]}? Now we're just one step away from the old spec :keys. Where did ::user go, what was the value of having a schema? Anyways, are there any news on the next take on spec that I'm missing? Couldn't find anything...

☝️ 3

with schema you can describe trees and not just one-level. For example, we can say, address is optional, but when you do give me an address, I need the zip code and the street. Before schema and select, this kind of a thing would result in an ad-hoc spec to be written, and we end up with a parochiality problem.


I still have two questions: 1. What's the use of ::user at the root in this case? 2. Why is schema needed for a nested select? I don't need a schema for ::address to say that if ::address exists in the map, I require it to contain ::zip and ::street.


Let's say we're dealing with a scenario where we're dealing with a seller and a buyer, and we need the address of both, then ::seller and ::buyer would be useful. With just ::user, it's not very useful, but if we don't have the ::user in there, that means it's assumed that the ::address is that of the user implicitly, making it context-sensitive. With ::user, we're making it clear that it is user information.


Cool. What's best way to begin trying out spec2, or is that discouraged until it's further along?


@mikeb I'd say it is discouraged at this point. We were tracking it closely at work for several months last year but it's still very fluid and very buggy and there's clearly still some "hammock time" needed. After talking to Alex in September/October about it, we decided to wait until he says it is "baked" before we try it again.

Alex Miller (Clojure team)21:07:22

instructions are in the readme if you want to try it as a git dep


I think it's going to be a big improvement over Spec 1, based on our foray into it last year, but be prepared for it to change/break quite a bit as it continues to evolve 🙂