Feature #15974
closed
Matz has approved this proposal.
Matz has approved this proposal.
\o/
This is a good feature, but I don't think this should belong to the "spec" as seems an implementation detail.
I think Ruby Spec considers warnings to be user-visible features, so does normally spec them. This prompts alternative implementations like JRuby and TruffleRuby to implement the same warning so that the user experience is the same on all implementations.
@Eregon (Benoit Daloze) will be able to give a definitive opinion on whether it should be spec'd or not.
- Status changed from Open to Closed
chrisseaton (Chris Seaton) wrote:
I think Ruby Spec considers warnings to be user-visible features, so does normally spec them. This prompts alternative implementations like JRuby and TruffleRuby to implement the same warning so that the user experience is the same on all implementations.
@Eregon (Benoit Daloze) will be able to give a definitive opinion on whether it should be spec'd or not.
Yes, exactly, it's a useful feature for other implementations to have too and it's user-visible so it's good to add to ruby/spec, similar to warnings.
Question: shouldn't this be an error rather than a warning? Defining a finalizer that immortalizes its object and can never run seems like an outright bug, not something that you should merely warn about in verbose mode only.
Question: shouldn't this be an error rather than a warning?
No, because it's possible to have a reference from the finaliser to the object when the finaliser is created, but then to later clear that reference and the finaliser to work properly. The specs cover this.
However this PR was reverted due to some bugs (I wrote it in a couple of hours at a hackathon and it was merged then and there, so not surprising it wasn't really fully baked yet!) I hope to get it back in at some point.
Ah, good point.
But maybe ObjectSpace.define_finalizer(obj, aProc)
should raise an error if aProc.binding.receiver.equal?(obj)
, because that's a reference that can never be cleared.
Yes we could do that, and enable it always as that'd be cheap.
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0