3 ms·
> 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
by 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&...