I was playing around with something similar to the OP and encountered this 
same problem using s/spec recursively. Yes, I get it that there are 
work-arounds, but it seems like this is a legitimate issue. s/spec as you 
say resolves at definition time, but the rest of the combinators (s/alt, 
s/and, s/keys, etc.) as far as I can tell are late binding. What's the 
rationale for s/spec behaving differently? If specs happen to get redefined 
later this could further complicate matters as everything defined with 
s/spec will reference the older spec. Why not just make s/spec late binding 
too and then there would be no such issue with recursive specs?

On Wednesday, July 20, 2016 at 2:12:44 PM UTC-4, Johan Jonasson wrote:
>
> It works! Thanks! 
>
> Seems like I have to learn more about s/spec.
>
> On Wednesday, July 20, 2016 at 5:46:20 PM UTC+2, Alex Miller wrote:
>>
>> s/spec is going to try to resolve that keyword during the definition. 
>> Does this do what you want?
>>
>> (s/def :html/element
>>   (s/spec (s/cat
>>                  :tag keyword?
>>                  :attrs map?
>>                  :children (s/* (s/alt :element :html/element 
>>                                                :string string?)))))
>>
>>
>> On Wednesday, July 20, 2016 at 10:38:41 AM UTC-5, Johan Jonasson wrote:
>>>
>>> I might have stumbled upon a bug in clojure.spec, while trying to define 
>>> a spec. This doesn't compile:
>>>
>>> (s/def :html/element
>>>   (s/cat
>>>    :tag keyword?
>>>    :attrs map?
>>>    :children (s/* (s/alt :element (s/spec :html/element)
>>>                          :string  string?))))
>>>
>>> The exception says: "Unable to resolve spec: :html/element".
>>>
>>> Is it a bug, or is there another way to define this?
>>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to