On Tue, Dec 23, 2003 at 11:07:53AM +0100, Elizabeth Mattijsen wrote:
> At 10:37 +0100 12/23/03, Leopold Toetsch wrote:
> >2) the Perl5ish declaration
> >
> > my $var : shared;
> >
> > is basically:
> >
> > $P0 = new SharedPerlUndef;
> >
> > OTOH:
> >
> > share($var);
> >
> > may need to morph $var into a shared reference, with an additional
> > indirection and memory overhead.
> >
> >(I don't know, what Perl5 does with an already used "$var", that is
> >turned into a shared var later - or even at runtime).
>
> $ perl5.8.2-threaded -Mthreads -Mthreads::shared -MO=Deparse -e 'my
> $a : shared = 1'
> use attributes ();
> ('attributes'->import('main', \$a, 'shared'), my $a) = 1;
>
> $ perl5.8.2-threaded -Mthreads -Mthreads::shared=share -MO=Deparse -e
> 'my $a = 1; share( $a )'
> my $a = 1;
> share $a;
>
>
> Both the share() function as well as the ":shared" attribute, operate
> at runtime in Perl5. This is especially awkward for the ":shared"
> attribute.
Sharing of lexical vars has to be done at run-time, since each time the
scope is entered, you need to create a new instance of the variable.
--
"Do not dabble in paradox, Edward, it puts you in danger of fortuitous
wit." -- Lady Croom - Arcadia