In core.match, what's the difference between predicates (:when) and guards (:guard)?

113 views
Skip to first unread message

retnuH

unread,
Dec 8, 2015, 4:18:09 PM12/8/15
to Clojure
I can't really figure out what the deal is with predicates.  They're not mentioned in the Basic/Advanced usage wiki pages at all.  The code for Guards and Predicates is basically identical.

The only difference that I've been able to find (beyond the spelling, obviously):

- predicates can only be symbols, i.e. they can't be function declarations (#() or (fn))

- predicates have to be pre-declared with defpred

Am I missing something?  Is there some use case that predicates fill that guards don't?

Cheers,

H

David Nolen

unread,
Dec 8, 2015, 9:40:03 PM12/8/15
to clojure
core.match will attempt to optimize matching :when clauses in the decision tree.

David

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hunter Kelly

unread,
Dec 9, 2015, 5:42:38 AM12/9/15
to clo...@googlegroups.com
Okay, thanks!

You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/6ESXmcPks60/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages