seqexp icon indicating copy to clipboard operation
seqexp copied to clipboard

Regex protocol implementations for Symbols and Vectors`

Open glchapman opened this issue 3 years ago • 0 comments

I suggest that both symbols and vectors should by default use equality tests in patterns, rather than be treated as predicate functions (both symbols and vectors implement AFn).

For example, I think it's natural if I want to match an empty vector to do something like this:

user=> (se/exec (se/cat []) (list []))
Execution error (IllegalArgumentException) at net.cgrand.seqexp/boot-grouping-vm$step$fn (seqexp.clj:352).
Key must be integer

On the other hand, I can't imagine ever wanting something like this:

user=> (se/exec (se/cat [1 2 3]) [0])
{:rest (), :match (0)}

Similarly, I think it's natural to expect symbols to act like keywords. Contrast:

user=> (se/exec (se/cat :foo) (list :foo))
{:rest (), :match (:foo)}

with:

user=> (se/exec (se/cat 'foo) (list 'foo))
nil

glchapman avatar Oct 18 '20 19:10 glchapman