Tobiwan has asked for the wisdom of the Perl Monks concerning the following question:

Hi there, I'm searching for more wisdom about typed lexicals. I found out, that all access to typed variables, which are declared like this: my MyClass $object = new MyClass() are checked at compiletime (use fields use this behavior). And I want to know, which module knows all about the variable accesses? Can I read out this table? Can I change the behavior? I found out, that all what I need to enable theese checks is, to create the Class-HASH "FIELDS" in MyClass like that:
package MyClass; use strict; use warnings; local %MyClass::FIELDS; BEGIN { %MyClass::FIELDS = ('_test' => 1); } sub new { bless ['PackageName', 'value_of_"_test"'], $_[0] } package main; my MyClass $t = new MyClass(); print $t->{'_test2'};
This throw an error at compiletime because "_test2" is not defined. But it expected, that the object is an arrayreference. I found some cryptic description for "avhv" (don't know what this is) and som Perl-XS C libaries with methods that starts with "pad_", but as I sad, it's very cryptic for me. Can anyone help? Are there wise monks out there and share wisdom with me :)

Replies are listed 'Best First'.
Re: Knowledge about typed lexicals and the access check
by Zaxo (Archbishop) on Apr 01, 2007 at 05:16 UTC

    You've hit a tricky question. That syntax is associated with attributes, base, and other half-formed parts of perl. You may want to avoid that until it stabilizes.

    What I know about the subject is covered in the thread my Dog $spot;.

    After Compline,
    Zaxo