nim-lang / RFCs

A repository for your Nim proposals.
135 stars 26 forks source link

The future of finalizers #504

Open mratsim opened 1 year ago

mratsim commented 1 year ago

Not a RFC per se but I don't see finalizers appearing in the roadmap (https://github.com/nim-lang/RFCs/issues/503, https://forum.nim-lang.org/t/9777) or any Nim v2 discussion (https://forum.nim-lang.org/t/9132)\

They don't even appear in the manual https://nim-lang.org/docs/manual.html or lifetime tracking hook docs https://nim-lang.org/docs/destructors.html#lifetimeminustracking-hooks.

With Nim v2 with have an opportunity to replace the finalizer syntax with =destroy which iirc was always the plan. And if it's not anymore, documentation on finalizers is missing.

So what's the plan here? Is that in roadmap 2023?

juancarlospaco commented 1 year ago

Finalizer is just Destructor?, or I am missing somethin' Stdlib should add destructors.

Araq commented 1 year ago

And if it's not anymore, documentation on finalizers is missing.

We map finalizers to destructors. Which is not entirely correct but it works well enough in practice. However, one can argue that we should deprecate finalizers for this reason.

arnetheduck commented 1 year ago

However, one can argue that we should deprecate finalizers for this reason.

+1 - ie finalizers have a very odd implementation where instantiating a type once with a finalizer changes all instances - even those that where created before or are created without the finalizer parameter .. same as shallowCopy, get rid of it