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 :)

In reply to Knowledge about typed lexicals and the access check by Tobiwan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.