Welcome! Please see the About page for a little more info on how this works.

+4 votes
in Clojure by
edited by

One way to look at type declarations in a static language is as a test which picks up potential incompatible code paths. E.g. data passed is incompatible with code. 

In static languages the effort to write the test is reduced by virtue of being declared inline with the code and inference allows a few annotations to permeate - having said that it seems Clojure’s spec features can be used achieve a similar results.

Do you use spec to get static typing like benefits? What are the limitations?

Edit: Reworked this as a question and moved my thoughts out to a gist...

https://gist.github.com/olivergeorge/9ae12592b49f8da4d911650b793dcbda

2 Answers

+1 vote
by

Could you summarize what question(s) you are actually asking here?

I read the whole piece but it seems to be more a set of observations than any questions that could be answered here.

by
edited by
Thanks for taking the time to read.

I’m interested in exploring the value and limitations of spec check in providing some of the benefits of static types.  

Perhaps my approach is too open ended.  

Is this the wrong place for encouraging discussion of successful techniques and things to avoid?

Edit: I’ve changed the title.
by
Like Quora and StackOverflow, it's a place to ask questions and get answers -- but I just couldn't tell what questions you were asking. I think if you can edit it to be more focused about what you're asking, so folks are clear what they're answering, that will help.

I don't see clojure.spec as comparable to static types so, for me, even with the new title worded as a question, I wouldn't know what to say as an answer (and we've been a very heavy user of clojure.spec since the first alpha builds of it, early in the 1.9.0 cycle).
by
Reworked and moved my thoughts out to a gist...

https://gist.github.com/olivergeorge/9ae12592b49f8da4d911650b793dcbda
by
Cool. Question is clear now. I'll be interested to see what answers you get!
by
The gist should be linked in the question I think.
by
Done. Thanks.
0 votes
by

Since you haven't had any answers to your question, I'll drop my recent blog post link here:

https://corfield.org/blog/2019/09/13/using-spec/

As you'll see from the post, it was originally written as an answer to a more open-ended question about Spec on Quora.

...