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

allow for multiple pre- and postcondition checks at same level #6

Open
sellout opened this issue Apr 26, 2011 · 2 comments
Open

allow for multiple pre- and postcondition checks at same level #6

sellout opened this issue Apr 26, 2011 · 2 comments

Comments

@sellout
Copy link
Owner

sellout commented Apr 26, 2011

Currently, if there are multiple conditions at the same level, we end up doing something like this:

(defmethod put :ensure "stack not empty & ITEM added to top" (item (object stack))
  (and (not (emptyp object))
       (eq (item object) item)))

However, this leads to less-specific than ideal condition reports. Something like either

(defmethod put :ensure "stack not empty" (item (object stack))
  (not (emptyp object)))
(defmethod put :ensure "ITEM added to top" (item (object stack))
  (eq (item object) item))

or

(defmethod put :ensure (item (object stack))
  (contract-check (not (emptyp object)) "stack not empty")
  (contract-check (eq (item object) item) "ITEM added to top"))

would allow us to give more specific condition reports.

@kisp
Copy link

kisp commented Jun 24, 2014

I was going to report this issue myself. :)

The second option, using contract-check is of course doable. The first one looks more composable, though. But how exactly would it work that CLOS does not interpret the second method as a redefiniton of the first?

@sellout
Copy link
Owner Author

sellout commented Jun 25, 2014

Well, if I knew how to implement the first one, it’d already be done 😉

But … just as we can distinguish between :ensure and :guarantee with the same specializers, it seems like we should be able to distinguish between different string qualifiers. But (and it’s been ages since I’ve looked at this) I think that compute-applicable-methods is called on each method group and errors if it finds methods with the same specializers. In which case, either

  1. different strings need to end up in different method groups (which I have some ideas about, but all of them expose some hackiness to the user); or
  2. we go full MOP, subclassing standard-generic-function and overriding compute-applicable-methods for it to allow for multiple methods with the same specializers.

The problem with number two is that it won’t play nicely with other people’s standard-generic-function subclasses. But that might only affect @edicl 😉

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