Details
-
Type:
Enhancement
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:
-
Patch:Code and Test
Description
So, tagged data structures are probably interesting in a relational context. Say you have a relation with some default logic about dogs:
(defna friendlyo [Dog-Or-Breed]
([:Spot] succeed)
([:Spike] fail)
([Other-Dog] (fresh [Breed] (dog-breed Other-Dog Breed) (friendlyo Breed)))
([(breed :miniature-dachshund)] fail)
([(breed :golden-retriever)] succeed)
;. . .)
Assume there's a (defmacro breed [t] `[:breed ~t]).
That's nicer than having to drop [:breed :golden-retriever] in there or whatever, since it's compile-time-checkable, less error-prone, reduces duplication, etc.
This little patch makes ex* expand macros in patterns so it doesn't treat e.g. (breed :golden-retriever) as introducing a new LVar called "breed". Test also provided.
Attachments
Activity
David Nolen
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
So, tagged data structures are probably interesting in a relational context. Say you have a relation with some default logic about dogs:
(defna friendlyo [Dog-Or-Breed] ([:Spot] succeed) ([:Spike] fail) ([Other-Dog] (fresh [Breed] (dog-breed Other-Dog Breed) (friendlyo Breed))) ([(breed :miniature-dachshund)] fail) ([(breed :golden-retriever)] succeed) ;. . .) Assume there's a (defmacro breed [t] `[:breed ~t]). That's nicer than having to drop [:breed :golden-retriever] in there or whatever, since it's compile-time-checkable, less error-prone, reduces duplication, etc. This little patch makes ex* expand macros in patterns so it doesn't treat e.g. (breed :golden-retriever) as introducing a new LVar called "breed". Test also provided. |
So, tagged data structures are probably interesting in a relational context. Say you have a relation with some default logic about dogs:
{code} (defna friendlyo [Dog-Or-Breed] ([:Spot] succeed) ([:Spike] fail) ([Other-Dog] (fresh [Breed] (dog-breed Other-Dog Breed) (friendlyo Breed))) ([(breed :miniature-dachshund)] fail) ([(breed :golden-retriever)] succeed) ;. . .) {code} Assume there's a (defmacro breed [t] `[:breed ~t]). That's nicer than having to drop [:breed :golden-retriever] in there or whatever, since it's compile-time-checkable, less error-prone, reduces duplication, etc. This little patch makes ex* expand macros in patterns so it doesn't treat e.g. (breed :golden-retriever) as introducing a new LVar called "breed". Test also provided. |
I'm surprised that this doesn't already work. We have support for unifying expressions in the pattern already. Look at line 1230 in tests.clj in the master branch.
So this should just work, no need to explicitly support macros as far as I can tell. If it's not working, then there's a bug.