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

+2 votes
in Spec by

I support the open map philosophy, but in regex contexts there is a problem if s/keys* continues parsing just because the next thing is a keyword followed by any?. Does the open map philosophy really add value in regex contexts?

Example

(s/def ::my-lang (s/cat :opts (s/keys* :opt-un [::opt1 ::opt2])
                        :body (s/* keyword?)))
;; if body consists of two keywords, they will be parsed as opts

1 Answer

+1 vote
by

Yes, it adds value in any place that supplies options (which may be variable and expand over time). Normally the variable args are at the end, so there's no ambiguity in that regard.

I think whatever you're spec'ing here has ambiguity in this regard and the difficulty of spec'ing is showing you that. (I find things that are hard to spec are usually telling you your data is fish.)

There are still some more cumbersome ways to spec this with the existing regex operators, especially using s/& to supply additional predicates around the opts.

...