On Fri, Jul 30, 2021 at 7:11 AM Leonardo Freua email@example.com wrote:
First line of the body vs line before the declaration doesn't feel like it makes much difference to me.
Usually, decorators or annotations are placed near the method signature, that is, at the beginning where any reading begins, because it's easier to see that method is deprecated or anything else that needs a decorator.
Putting this information inside the method body, you end up putting information that is not the method's responsibility to provide, this ends up mixing with what the method actually does, it's more information to read in a debug or in maintenance that the method will need to receive. Not to mention the fact that sometimes depreciation messages can be longer than 2 lines.
Most programming languages have some way of expressing depreciation, and it's usually close to the method signature.
One advantage of language support for deprecation can be an "entry point only" warning - if a regular function calls a deprecated function, there's a warning, but if a deprecated function calls another deprecated function, there won't be. Whether this is worth implementing here is a separate question, but it would certainly be easier to do with a decorator than an explicit warn() call.