quil-lang / magicl

Matrix Algebra proGrams In Common Lisp.
BSD 3-Clause "New" or "Revised" License
238 stars 44 forks source link

Recompiling define-extensible-function form doesn't define the backend function #191

Closed Yehouda closed 1 year ago

Yehouda commented 1 year ago

https://github.com/quil-lang/magicl/blob/e904b4390a04a3af5a8e9b5ef4af65222ca3dcce/src/high-level/util.lisp#L112

With the code as it is, compiling and loading a file with a define-extensible-function works first time, but if you compile again after loading it does not define the backend function, and you have a "broken" (missing the backend function) file. Loading this file in a fresh process will miss the backend implementation.

I don't see a reason why it needs to check at all, rather than do the define-backend-function form uncodnitionally. Inside define-backend-function, initialize-function-for-implementations checks again anyway, and the rest is just a defun.

stylewarning commented 1 year ago

I agree with you, this is the correct way to do it. Thanks!