Fork me on GitHub
#clojure-dev
<
2019-08-29
>
vlaaad07:08:30

is it unavoidable to have separate spec/alt and spec/or? why can't we use spec/or as regex op?

vlaaad07:08:15

same with spec/& and spec/and

vlaaad07:08:17

same with spec/keys* and spec/keys

vlaaad07:08:49

there is already a way to escape "regex context" by using spec/spec, it would be nice to have slimmer api..

vlaaad07:08:52

hmm, actually, both spec/or and spec/alt work in regex context

Alex Miller (Clojure team)12:08:28

They are not the same in a regex context

Alex Miller (Clojure team)12:08:33

If you have another regex underneath the alt it can combine with regexes above in ways that or cannot

Alex Miller (Clojure team)12:08:17

So yes, they are both needed

vlaaad13:08:32

it just feels they could be semantically the same

Alex Miller (Clojure team)13:08:58

they are semantically different

Alex Miller (Clojure team)13:08:23

just as s/coll-of and s/* are semantically different

vlaaad13:08:27

what is the difference in their semantics?

Alex Miller (Clojure team)13:08:56

regexes combine to describe the structure of a single collection. non-regexes do not.

vlaaad13:08:10

it feels like with regexes and s/spec "escaping" there is no need in coll-of/and/or?

vlaaad13:08:48

you can express the same things

Alex Miller (Clojure team)13:08:23

specs are intended to express meaning to the reader and these have different meanings

Alex Miller (Clojure team)13:08:55

whether you can turn the crank on two things and get the same answer is to some degree beside the point

vlaaad13:08:08

I think I understand

Alex Miller (Clojure team)13:08:18

they are completely different implementations and likely have very different perf characteristics in validation

Alex Miller (Clojure team)13:08:31

also need to consider generation, etc

vlaaad13:08:13

yeah, right