Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex protocol implementations for Symbols and Vectors` #12

Open
glchapman opened this issue Oct 18, 2020 · 0 comments
Open

Regex protocol implementations for Symbols and Vectors` #12

glchapman opened this issue Oct 18, 2020 · 0 comments

Comments

@glchapman
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant