有人能解释一下,下面的例子有什么问题吗?为什么它会抛出StackOverflowError异常?
(s/def ::tag keyword?)
(s/def ::s string?)
(s/def ::n number?)
(s/def ::g
(s/cat :tag (s/? ::tag)
:ex (s/alt :string ::s
:number ::n
:and (s/+ ::g)
)))
(s/conform ::g '["abc"])发布于 2017-05-09 11:58:32
类似于Alex在这个谷歌小组的讨论中所指出的,s/+试图在定义期间解析::g。
这应该能做你想做的,我想:
(s/def ::g
(s/spec (s/cat :tag (s/? ::tag)
:ex (s/alt :string ::s
:number ::n
:and ::g))))
; REPL
user=> (s/conform ::g [:foo [:bar "abc"]])
{:ex [:and {:ex [:string "abc"] :tag :bar}] :tag :foo}https://stackoverflow.com/questions/43868064
复制相似问题