ClojureScript

IHash implementation for regular expressions.

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Regular Expressions don't implement the IHash protocol at the
moment. This means they can't act as keys in a map.

When eval'ing the form {#"x" 1} the following error is raised:
#<Error: No protocol method IHash.-hash defined for type object: /x/>

A possible implementation could be:

(extend-type js/RegExp
IHash
(-hash [o] (hash (str o))))

Activity

Hide
David Nolen added a comment -

doing this triggers a warning from the Google Closure Compiler that RegExps cannot optimized. I'm not sure what that means exactly will need to hear from others.

Show
David Nolen added a comment - doing this triggers a warning from the Google Closure Compiler that RegExps cannot optimized. I'm not sure what that means exactly will need to hear from others.
Hide
David Nolen added a comment -

again closing this for now if people want this - they can do it in their own projects.

Show
David Nolen added a comment - again closing this for now if people want this - they can do it in their own projects.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: