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

Is there any way to remove/clear phrases? #17

Open
leblowl opened this issue Jul 2, 2018 · 2 comments
Open

Is there any way to remove/clear phrases? #17

leblowl opened this issue Jul 2, 2018 · 2 comments

Comments

@leblowl
Copy link
Contributor

leblowl commented Jul 2, 2018

Thanks for the great library, I really like the design of the user interface (defphraser specifically). I stumbled upon an odd issue that may not be common, but it caused me to scratch my head for a few moments, so I'd like to share in case anyone else runs into it. When you define a phraser with dispatch on the :via keyword, and then delete it and re-define the same phraser without dispatch (within the same REPL session), the dispatched version will shadow the non-dispatched version - which is what you would expect, but for REPL development it may be confusing since your current phraser is not actually working. I am not sure how to clear the phrase storage besides a REPL reset.

@alexanderkiel
Copy link
Owner

I use a multi method internally to register phrasers. What do you mean by "deleting a phraser"? Deleting a phrase is only possible by using remove-method on the multi method. Can you please post your REPL session?

But you are right, there should be a way to remove phrasers. There is already remove-default! which is not documented yet. I'll think about the best way to remove normal phrasers and phrasers with `:via.

@leblowl
Copy link
Contributor Author

leblowl commented Jul 2, 2018

I am referring to removing the method for a phraser, like you explain.

For example:

(defphraser pos-int?
  [_ _]
  "Please enter a positive integer.")

and

(defphraser pos-int?
  {:via [::year]}
  [_ _]
  "The year has to be a positive integer.")

are actually two entirely different phrasers. But in the REPL if you were to do something like this:

=> (defphraser pos-int?
       [_ _]
       "Please enter a positive integer.")
#multifn[phrase* 0x7ffa2c90]

=> (defphraser pos-int?
       {:via [::year]}
       [_ _]
       "The year has to be a positive integer.")
#multifn[phrase* 0x7ffa2c90]

The second pos-int? is always going to shadow the first pos-int? when phrasing problems for ::year. It is not clear how to remove a phraser. When evaluating expressions in the REPL directly, you can tell that the library uses a multi method, but when you evaluate a buffer/file (e.g. in Emacs with Cider) you don't get this information and so it's even more unclear in that case. Also, I'm not super familiar with multi methods but just knowing that you use a multi method for registering phrasers doesn't actually help me in removing a phraser's method - I would also need to know the dispatch value that you use for registering the method - is that correct? Thanks

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

2 participants