lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Wed, Sep 13, 2023 at 1:03 PM Mouse <mouse@rodents-montreal.org> wrote:
>>> You can already solve it with a wrapper, something like; [...]

>> Sure, but that warns when the function is called, not when its name
>> is used.  [...]
> Deprecation in other languages is handled at compile time, which isnt really$

Strictly speaking, maybe, functions do not have names.  But they are
referred to with names.  It is that, the name which is used to refer to
the function, that I would attach the deprecation to.  (This makes
sense to me especially because you may want to simply rename some
functionality, in which case you want to deprecate the old name, not
the functionality itself.  Also, attaching the deprecation to the name
instead of the thing allows you to deprecate things other than
functions.)


Functions are looked up dynamically. In this code:

T = require("mymodule)
T.NAME("foo")

T is a value returned by 'require', and at compile time there is no knowledge of what T is, let alone that you'd know which keys indexing T would have a deprecated flag attached. Lua modules get compiled before the modules they depend on, and only when you run the module do dependent modules get compiled and run, so any 'deprecated' info comes in too late.

Ge'