Fork me on GitHub
#clojure-spec
<
2019-01-03
>
y.khmelevskii09:01:31

Hi everyone! Just curious, does anybody know when clojure/clojurescript with spec/schema and spec/select will be released? I like this idea and want to try it 🙂

Alex Miller (Clojure team)13:01:13

We have not started developing it yet, so not soon :)

y.khmelevskii20:01:28

thank you for info 🙂

borkdude16:01:04

what is generally preferred in specs? (s/nilable (s/or ...) vs (s/or :nil nil? …) when enumerating alternatives

Alex Miller (Clojure team)16:01:20

the first is perf optimized

borkdude16:01:15

it might also be more robust, since some predicates can crash on nil

Alex Miller (Clojure team)16:01:16

the generator for nilable is also intentionally unbalanced so it only produces nils 10% of the time

Alex Miller (Clojure team)16:01:50

whereas the latter will be 1/n where n = # of options

borkdude16:01:24

can something similar be said about s/alt vs s/or in a regex?

Alex Miller (Clojure team)16:01:01

not sure what you mean. do you mean nilable vs alt on nil?

Alex Miller (Clojure team)16:01:51

if so, then that’s a different situation as s/nilable is not a regex and won’t compose in the same way as s/alt with other regex ops

borkdude16:01:56

no sorry, (s/cat :foo int? :x (s/alt ...)) vs s/or instead of alt

borkdude16:01:11

so independent of nil

borkdude16:01:26

I’m looking for an argument other than “alt belongs in regex”

Alex Miller (Clojure team)16:01:31

s/alt is a regex op and composes with other regex ops to describe a single sequential structure

Alex Miller (Clojure team)16:01:03

so acts as an independent value

borkdude16:01:19

sometimes the spec for :x can be taken apart and then it only makes sense to do it with or to make it re-usable on a single value

Alex Miller (Clojure team)16:01:49

it depends here on what … is

borkdude16:01:09

right, … can contain other regex specs

Alex Miller (Clojure team)16:01:21

in some cases, there is no perceptible difference

borkdude16:01:23

so, it depends then

Alex Miller (Clojure team)16:01:43

there are cases where you might want s/alt and some where you might want s/or

Alex Miller (Clojure team)16:01:10

if you’re describing alternatives of the sequential structure, then probably s/alt

Alex Miller (Clojure team)16:01:42

if you’re describing alternate value sets that occur at a particular point in the structure, then probably s/or

Alex Miller (Clojure team)16:01:25

usually the s/alt case will contain more regex ops inside the … whereas the s/or will not

borkdude16:01:33

clear, thanks!