Error formatting macro: pagetree: java.lang.NullPointerException
Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current  |   View Page History

Motivation

Want general purpose pattern matching, binding, unification. Possibly split into multiple services a la carte. My initial use case (generalizing how to limit reflection results) needs only matching, no binding or unification.

Issues

Based on a combination of my needs, the matching implementation I have proposed for clojure.data / reflection, and Drew Colthorp's matchure:

  • desirable to support Clojure's equality partitioning
    • will never want assoc lists
    • limits cross-partition uses of existing destructuring
  • minimize need for special forms
    • especially those such as matchure's "and" and "or" that usurp Clojure names
  • so far, prefer argument order as in matchure
    • match is the "object", comes first
    • con: hurts ability to thread candidates via ->
  • a la carte?
    • matching without binding is super simple
    • matchure does binding but no unification
  • meaning of symbols
    • in matchure they are equality-matched (with some exceptions)
    • think I prefer evaluating them (quote them to prevent)
    • latter makes it easy to build new match patterns at runtime
  • what is the syntax for guard-and-bind?
    • matchure uses (and (pred form) ?varname)
    • would like to find something that is used nowhere else
  • currently no way to say "exactly this map/set", as extra keys are ignored
  • currently no way to say "this value must not be present"
  • considered an rejected parameterizing match with an atom-matching function
    • would allow different interpretations of e.g. string matching (case-insensitive, partial, etc.)
    • regexes cover all the string scenarios, and design already supports arbitrary functions
Labels: