Closed guicho271828 closed 9 years ago
For example, ppcre-pattern can be implemented as follows:
(defpattern ppcre (regex &rest subpatterns)
`(and (type string)
(access #'(lambda (x)
(nth-value 1 (ppcre:scan-to-strings ,regex x)))
(and (vector ,@subpatterns))))
pros: we don't have to implement/export the new/internal API.
cons: compiler efficiency?
Reading Fabrice et. al. It seems like the "constructor" is one of the keys in the algorithm, so instead of just 'accessor', "constructor" is what should be exported.
15-minutes hack, but it works. If we further expand this strategy, almost all constructor patterns can be derived from the combination of this one and other primitive patterns e.g. type/and/guard patterns.
Note: of course you don't have to merge this commit.