From: [email protected]
> What is the precise difference between the two ways of generating an
> inside-out-object?
>
> 1/
> my $node = bless \do { my $anonymous }, ref($class) || $class;
>
>
> 2/
> my $a;
> my $node = bless \$a, ref($class) || $class;
>
> In other words, why is it suggested in most books, web to have an
> /anonymous/ scalar?
If you do not touch the $a anywhere in the rest of the enclosing
block then the two are equivalent. The do{} trick is there just to
create a block as small as possible to ensure the variable is not
used.
I would actually find this easier to read:
my $node = do {
my $anon;
bless \$anon, $class;
};
I don't really like the \do.
Jenda
===== [email protected] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/