The class declaration code looks something like:
package Foo; #use strict; use Class; class { attr qw( foo bar ); isa 'Foo::Base'; method floozle => signature (Int, Int), body { my ($v1, $v2) = @_; $self->foo( $v1 ); return $self->get_bar( $v2 ); }; }; package main; my $obj = Foo->new; $foo->set_foo( 3 ); $foo->floozle( 9, 5 ); # These croak $foo->floozle() $foo->floozle( 9, 'a' );
The astute observer will notice that $self is never declared anywhere, yet this does work just fine ... so long as you're not under strict. And, I have no idea why.
Class::import() (called during use) creates $Class::self in the caller's namespace. I would think that the existence of this variable before the reference to $self is compiled in the body declaration would satisfy strict. But, it apparently doesn't. And, it's the oddest set of errors:
Variable "$self" is not imported at t/lib/Foo.pm line ##. Global symbol "$self" requires explicit package name at t/lib/Foo.pm l +ine ##.
"use diagnostics" doesn't help much:
Variable "%s" is not imported%s (F) While "use strict" in effect, you referred to a global variabl +e that you apparently thought was imported from another module, becau +se something else of the same name (usually a subroutine) is exported + by that module. It usually means you put the wrong funny character o +n the front of your variable.
So, my questions are:
The goal here is to avoid string eval. It's ok if a solution either requires a specific Perl version or XS. In fact, I'd love it if the solution required XS - I've been looking for an actual thing for me to get my feet wet in XS.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |