screamer icon indicating copy to clipboard operation
screamer copied to clipboard

Generic function support?

Open kchanqvq opened this issue 4 years ago • 1 comments

Does this work with generic functions? I was always assuming "no" and that's a major pain point when using it.

I've had enough and would probably look into implementing support for it. Do you think it's doable?

kchanqvq avatar Oct 03 '21 05:10 kchanqvq

Sorry about the long response time!

If you mean, "can I call generic functions from screamer/non-deterministic functions", the answer is yes. (At least I don't immediately see any reason why it would not work, but it's been a good while since I've last actively used or worked on Screamer, so maybe I forget?)

If you mean, "can I define a generic screamer/non-deterministic function", the answer is no. I was going to say that excluding CALL-NEXT-METHOD support it would probably be relatively speaking simple, but trying to outline how it would work I started thinking it's not as simple. The problem is that I don't remember exactly how the Screamer code walking transformation works. I still think it's doable, but not sure how tricky.

I would start with something like:

(define-screamer-method foo ((x some-class))
   ...body...)

=>

(define-screamer-function #:foo-method-gensym (x)
    ...body...)
    
 (defmethod foo ((x some-class))
    (#:foo-method-gensym x))

generating a separate ND function for each ND method. CALL-NEXT-METHOD won't work, and I don't frankly remember what you need to do to enter ND context from non-ND context - frank I think what I've outline above doesn't work quite like that... but it's what I would start with, then figuring out why it doesn't work.

nikodemus avatar Feb 05 '22 12:02 nikodemus