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

Compile-time deprecation warnings #7027

Closed
j8r opened this issue Nov 5, 2018 · 3 comments
Closed

Compile-time deprecation warnings #7027

j8r opened this issue Nov 5, 2018 · 3 comments

Comments

@j8r
Copy link
Contributor

j8r commented Nov 5, 2018

There are no proper way to deprecate methods/objects.
The common way is to add a comment like # TODO: Remove after 0.28.0 but the end user won't be informed of this future breaking-change when compiling its program. (S)he will only notice the missing object/methods when using the new release that remove them, and has to read the CHANGELOG to figure out what breaking-change is the source of this, and what to do.

Solution

C# has the Obsolete annotation for deprecation, java has @Deprecated

An annotation can be used to deprecate method and objects, along with a deprecation message:

@[Deprecated("will be removed in 0.28.0, use `new_method` instead")]
def old_method
end

This will print a colored deprecation notice like: Deprecated: old_method: will be removed in 0.28.0, use `new_method` instead"

This could also add a deprecation message below the method in the generated docs.

@RX14
Copy link
Contributor

RX14 commented Nov 5, 2018

This can be - and has been - done by putting

def old_method
  {{ puts "old_method is depecated and will be removed in xxx, use yyy" }}
end

see https://github.com/crystal-lang/crystal/pull/3563/files#diff-4760ade465a047460c75394908828da7R377

I'm not so sure we need a better solution for this right now, but later (close to 1.0) adding one will help external tooling.

@j8r
Copy link
Contributor Author

j8r commented Apr 12, 2019

I guess we can consider this issue solved with #7661 and all the other PRs @bcardiff 😄
This functionality was implemented faster than I thought. A sign that Crystal is gaining stability and approaching to 1.0?

@straight-shoota
Copy link
Member

Quick adoption of new features is not necessarily a sign of stability 😝

And it's not complete yet. Discussion continues in #7655 👍

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

No branches or pull requests

4 participants