2 ms·
...module that relies on specific undefined behavior... You call Perl 5's use of reference counting "undefined behavior"? It has been documented behavior for
by btilly 11y ago
...module that relies on specific undefined behavior...
You call Perl 5's use of reference counting "undefined behavior"?
It has been documented behavior for as long as Perl 5 has existed. The resulting destruction mechanics have been relied on by the core module http://perldoc.perl.org/SelectSaver.html http://perldoc.perl.org/SelectSaver.html for the same time. Furthermore any interesting XS program is likely to make use of the relevant macros SVREFCNT_int and SVREFCNT_dec.
Therefore this is NOT something that can be changed in a point release. It is a fundamental part of how Perl 5 works. And the fact that it is a fundamental incompatibility with Perl 6 plans is something that people have been aware of for a decade.
- kbenson 11y ago> You call Perl 5's use of reference counting "undefined behavior"? No, I call counting on the fact that items with no references will be reclaimed (triggering DESTROY) immediately when they go out of scope undefined behavior. The fact that it happens very fast in most cases because it's reference counted and not garbage collected is not something that should be counted on. In fact, I'm pretty sure there are cases where in very tight loops, DESTROY isn't called immediately on scope end. I vaguely recall having to deal with that problem (but it could just as likely been a bug of mine that appeared to indicate that until I found it).
- kbenson 11y agoFollowup, since it's too long since my reply to edit: How are you assuming Inline::Perl5 works? Did you look into it and these are issues you found, or are these from how you assume it works? Inline::Perl5 spins up an embedded perl5 interpreter (libperl I assume), and handles the data marshaling transparently. I assume (having not looked too closely at it's implementation), that it's sort of like a reverse XS. It looks into the perl5 guts, runs perl5 code, and exposes variables and functions to Perl 6. I see no reason to assume it wouldn't be using SVREFCNT_int and SVREFCNT_dec or equivalents as needed on scope changes to handle this. In fact, looking at the Inline::perl5 repo now, it appears they are doing quite a bit with the refcnt functions[1]. 1: https://github.com/niner/Inline-Perl5/search?utf8=%E2%9C%93&q=refcnt&type=Code https://github.com/niner/Inline-Perl5/search?utf8=%E2%9C%93&...