is it possible to use the deprecated pragma on a proc? for example, the following code works:
{.deprecated: [int: uint]}
but the this code:
proc foo*() = discard
proc bar*() = discard
{.deprecated: [foo: bar]}
gives the error:
Warning: the .deprecated pragma is unreliable for routines [User]
Error: redefinition of 'foo'
@emekoi, that's because deprecated will add a symbol for foo as well. Since foo is deprecated, the Nim compiler expects it to be removed and replaced with bar so that any calls to foo will redirect to bar.
If you change your code to the below, it will work just fine, barring the warnings (I'm not sure about the deprecated pragma being unreliable for routines, but perhaps it's still being worked on)
proc bar*() = echo "bar"
{.deprecated: [foo: bar]}
foo()
outputs:
Hint: system [Processing]
Hint: y [Processing]
y.nim(2, 19) Warning: the .deprecated pragma is unreliable for routines [User]
y.nim(4, 1) Warning: use bar instead; foo is deprecated [Deprecated]
y.nim(4, 1) Warning: use bar instead; foo is deprecated [Deprecated]
Hint: [Link]
Hint: operation successful (12024 lines compiled; 0.140 sec total; 16.301MiB peakmem; Debug Build) [SuccessX]
Hint: /home/joey/Downloads/scratch/y [Exec]
bar
You can also do:
proc foo*() {.deprecated: "use bar instead".} = discard
proc bar*() = discard
foo() # Warning: use bar instead; foo is deprecated [Deprecated]