You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Destructors are useful for RAII-style scope-based utilities. As such, they can be seen as a better and more flexible defer, given that they are reusable.
However, to use them as such, one needs to create an instance somewhere whose only purpose is to go out of scope at the right moment and that variable will never be used by regular code - the custom destructor itself is the usage.
typeDefer=objectproc`=destroy`(x: X) =echo"this is the meaningful part of using Defer"procf() =var x: Defer# this should result in no hint
As an alternative, a separate hint could be given for the code above - this would allow applications to turn the normal "XDeclaredButNotUsed" hint into an error while leaving this usecase alone.
Nim Version
2.2.0
Current Output
Expected Output
Known Workarounds
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Description
Destructors are useful for RAII-style scope-based utilities. As such, they can be seen as a better and more flexible
defer
, given that they are reusable.However, to use them as such, one needs to create an instance somewhere whose only purpose is to go out of scope at the right moment and that variable will never be used by regular code - the custom destructor itself is the usage.
As an alternative, a separate hint could be given for the code above - this would allow applications to turn the normal "XDeclaredButNotUsed" hint into an error while leaving this usecase alone.
Nim Version
2.2.0
Current Output
Expected Output
Known Workarounds
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: