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

slot-value-using-class to mark deprecated methods and add more metadata in general? #2982

Open
aartaka opened this issue May 25, 2023 · 7 comments
Labels

Comments

@aartaka
Copy link
Contributor

aartaka commented May 25, 2023

Maybe add a slot-value-using-class method for deprecated slots that warns the user on each read/write. Or maybe just on the first one.

Originally posted by @Ambrevar in #2978 (comment)

@aartaka aartaka mentioned this issue May 25, 2023
7 tasks
@jmercouris
Copy link
Member

Hm, very interesting idea. Very interesting...

@Ambrevar Ambrevar added the high label May 26, 2023
@Ambrevar
Copy link
Member

Ambrevar commented Jun 8, 2023

Something signaled by @aadcg is that before releasing 4.0 we should grep all the "Deprecated ... Remove with 4.0".

@Ambrevar
Copy link
Member

Ambrevar commented Jun 8, 2023

Something else that could help with deprecated functions / methods:

(uiop:with-deprecation ((uiop:version-deprecation (asdf:system-version :nyxt)
                                                  :style-warning "3.2"
                                                  :warning "3.4"))
  (defun foo ()
    "Foo docstring"
     17))

We could probably leverage this to deprecate slots via MOP.

@aartaka
Copy link
Contributor Author

aartaka commented Jun 8, 2023

So what UIOP uses is compiler macros. Which is easy: generate a compiler macro around the accessor generic function and signal the error there:

(define-compiler-macro ACCESSOR (&whole whole object)
  ;; Check for the type to avoid signaling deprecation for unaffected
  ;; accessors. FIXME: allows only one deprecation per accessor (=
  ;; only one of (name buffer) and (name window) would signal
  ;; deprecation if both are marked as deprecated here)...
  (when (typep object 'CLASS)
    ;; Useful for debugging, given the notoriously opaque macro
    ;; expansion mechanisms.
    (let ((form ',whole))
      ;; Should it be an `error'? UIOP does warnings on minor versions
      ;; and errors on major versions. But Nyxt handles lots of errors
      ;; gracefully enough by ignoring them.
      (error
       ;; We have to write this `deprecated' condition ourselves.
       'deprecated :version VERSION :form form :text "Deprecated in favor of NEW-ACCESSOR."))))

This approach is safe to use in nclasses, for example.

EDIT: unfinished sentence.

@Ambrevar
Copy link
Member

Ambrevar commented Jun 8, 2023

But that would fail if there is no accessor or if slot-value is used.
Instead would could leverage slot-value-using-class to ensure the deprecation message is printed.
That said, we almost never export slots without accessors, so it's not so important for the users. The point of using slot-value-using-class is that it triggers a warning even for core devs.

@aartaka
Copy link
Contributor Author

aartaka commented Jun 9, 2023

That said, we almost never export slots without accessors, so it's not so important for the users.

Yes, so we can go with a simpler solution before getting to heavy MOP artillery :P

The point of using slot-value-using-class is that it triggers a warning even for core devs.

Yes, that's a benefit, but the point above kinda makes it overkill :)

@Ambrevar
Copy link
Member

The MOP based approach is trivial to implement though with https://github.com/some-mthfka/slot-extra-options, it's just

  • One "extra option" declaration,
  • One slot-value-using-class specialization against user-classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants