On Sunday 30 May 2010 22:36:42 Gabor Szabo wrote:
> On Sun, May 30, 2010 at 7:18 PM, Yuval Kogman <[email protected]>
wrote:
> > In the context of Want it just checks if the retop operation involves a
> > boolean operator such that SvTRUE of the return value is the only thing
> > ever used.
> > my $foo = foo();
> > if ( $foo ) { # not boolean context
> >
> > if ( foo() ) { # boolean context
>
> So I wanted to show how
> if ( $foo ) {
> is a boolean context and started to write an example:
>
> use strict;
> use warnings;
>
> tie my $z, 'X', 1;
> print $z;
>
> package X;
> use strict;
> use warnings;
> use Want;
>
> sub TIESCALAR {
> my ($class, $self) = @_;
> return bless \$self, $class,
> }
>
> sub FETCH {
> my ($self) = @_;
> print "ok" if want('BOOL');
> return $$self;
> }
>
>
> the response was surprising:
>
> Segmentation fault
>
> using v5.10.1 that comes with Ubuntu 10.4 and Want 0.18
>
> the call to 'want' generates this.
>
> Can someone with a newer version of perl confirm this?
>
{{{
shlomi:~$ ~/apps/perl/5.12.0/bin/perl5.12.0 test.pl
Segmentation fault
shlomi:~$
}}}
perl-5.12.0 installed from source (with a small patch to make sure PDL's
lvalue assignment works properly in the debugger.) on Mandriva Cooker on a
P4-2.4GHz machine (x86-32). It also happens with the standard
perl-5.10.1-8mdv2010.1 . Nice catch!
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Interview with Ben Collins-Sussman - http://shlom.in/sussman
God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl