Re: using weak refs and requiring 5.6

Jonathan Swartz <[email protected]>
Newsgroups gmane.comp.web.mason.devel
Message-ID <[email protected]>
>>* Is Scalar::Util::weaken() stable and performant enough to use more
>>extensively in Mason? The docs for Perl 5.6.0 say that weak references
>>are still experimental, but I never found a corresponding doc to say
>>that they are now stable. Does the stability vary depending on Perl
>>version? And I saw this performance patch against 5.8 -
>>http://aspn.activestate.com/ASPN/Mail/Message/perl5-porters/1506613
>>which I didn't really understand but worried me.
> 
> 
> I doubt they'll ever leave the core, since they're used by a number of
> CPAN modules, and are the regularly recommended solution for circular
> reference problems.  The patch in the message you pointed at must be in
> core now, because with 5.8.4 the code that took 55 seconds for the poster
> takes 0.349 seconds for me.

Good to know.

> 
> Stability-wise I've not seen many bug reports for them on p5p, but I
> really have no idea how well they work for 5.6.1.  OTOH, we already use
> them in Mason, and we've never had a bug report from someone using 5.6.1+
> regarding a crash that seemed at all related to using it, so I suspect
> it's a non-issue.

Yes, we do use them, but for example under the current usage it is very 
unlikely that someone would end up using a freed (undef) weak ref, 
whereas under the new usage it would be more likely, even expected. That 
automatic undef behavior always seemed magical to me but hopfeully it is 
just as stable as the rest of it.

> 
> 
>>* I remembered vaguely discussing that we're going to require 5.6
>>starting with Mason 1.3, so Scalar::Util::weaken should be available
>>everywhere, right? Should we require 5.6.0 or 5.6.1? I know that the
>>former is problematic and unstable, but lots of default setups still use
>>it. I don't want to leave them out in the cold unless we feel it'll be
>>especially unstable in conjunction with Mason and weakrefs.
> 
> 
> We should require 5.6.1.  5.6.0 is so busted.  I don't know of many modern
> OS/distros that use 5.6.0 these days.  In fact, I'd expect Mason not to
> work with 5.6.0 as it is, because Params::Validate, Devel::StackTrace, and
> I think maybe other modules used by Mason all have problems under 5.6.0.
> 

I agree about 5.6.0...That said, I've seen several Mason 5.6.0 setups 
that work, albeit with the occasional "Bizarre copy of array" error. I 
know it was the default for a while on some distros, and you know how 
rarely some environments upgrade. So perhaps we should leave it at 
"require 5.6.0", but document that Mason is only officially supported 
for 5.6.1 and later.

Hmmph. We should get a survey of Mason users and what versions of Perl 
and mod_perl they're using, so we're not just taking guesses. Maybe a 
web form so that users on the site can fill in their system details.

> Scalar::Util went into the core with 5.8.0, but weaken works with 5.6.1.
> The only problem we're likely to run into is that Scalar::Util will
> install a pure Perl version of itself on systems without a compiler.  The
> Perl version doesn't support weaken().  So we'll want to detect this at
> install time _and_ run time.
> 

Good point. So we should leave in the CAN_WEAKEN check anyway. Those 
without weaken() can avoid the latest usage by just not using 
static_source mode.

Jon



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.