<?xml version="1.0" encoding="windows-1252"?>
<node id="281932" title="Forks.pm dilemma" created="2003-08-07 11:38:35" updated="2005-08-04 12:46:35">
<type id="120">
perlmeditation</type>
<author id="272239">
liz</author>
<data>
<field name="doctext">
I was checking [cpan://forks|forks.pm] to make sure it will run under 5.8.1 (it will) and finally looked at the problem of running it under 5.6.x (it doesn't).
&lt;P&gt;
This is basically the problem:
&lt;code&gt;
share( $variable );
&lt;/code&gt;
The share subroutine is actually an XS routine that has this special prototype:
&lt;code&gt;
    PROTOTYPE: \[$@%]
&lt;/code&gt;
This prototype was introduced somewhere in the 5.7 track.  So in 5.6.x I can't use that (I verified this on p5p). Simply removing the prototype and then having to specify a reference when calling share(), works:
&lt;code&gt;
share( \$variable );
&lt;/code&gt;
Of course, it doesn't work in 5.8.x then, but I think that's fixable.  But then the user's source code becomes incompatible with the real [cpan://threads] module.
&lt;P&gt;
So before I start doing that, I figure I put the dilemma to the Monks.  I see the following options:
&lt;UL&gt;
&lt;LI&gt;&lt;I&gt;Forget about supporting pre 5.8.x&lt;/I&gt;&lt;BR&gt;
This is sad, because one of the reasons for me to develop forks.pm was to allow people to try out threaded programming in 5.6.x without having to upgrade.  The only advantage to this proposal would be that you do not need a threaded 5.8.x perl to be able to run (as opposed to threads.pm, which needs perl with threads enabled).
&lt;P&gt;
&lt;LI&gt;&lt;I&gt;Support 5.6.x, forces references everywhere&lt;/I&gt;&lt;BR&gt;
This would make the user's source incompatible with current threads and forks users.  So if you would want to migrate to "true" threads, you would need to change your code with every call to share(), lock(), cond_wait(), etc.  But it would allow you to migrate from 5.6.x to 5.8.x without any problem.
&lt;P&gt;
&lt;LI&gt;&lt;I&gt;Support 5.6.X, force references in 5.6.x, force direct otherwise&lt;/I&gt;&lt;BR&gt;
This would mean that when code using forks is migrated from 5.6.x to 5.8.x or higher, it stops working because you need to remove the reference from each call to share(), lock() etc.
&lt;/UL&gt;
Any suggestions with regards to this dilemma are deeply appreciated.
&lt;P&gt;
Liz
&lt;P&gt;
&lt;B&gt;Update&lt;/B&gt;&lt;BR&gt;
It seems possible to use a source filter for 5.6.x.  I think I'll give that a try.  Thanks everyone for their feedback!
&lt;P&gt;
&lt;B&gt;Update 2&lt;/B&gt;&lt;BR&gt;
&lt;PRE&gt;
The URL

    http://www.liz.nl/CPAN/forks-0.04.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/E/EL/ELIZABETH/forks-0.04.tar.gz
  size: 27883 bytes
   md5: 5855b7f32f260d5ed04b3a34671f1866

No action is required on your part
Request entered by: ELIZABETH (Elizabeth Mattijsen)
Request entered on: Mon, 11 Aug 2003 00:37:06 GMT
Request completed:  Mon, 11 Aug 2003 00:45:48 GMT
&lt;/PRE&gt;</field>
</data>
</node>
