The reason for the extra layer of indirection is that when I wrote it I was thinking that you would tie to the type of the variable. So you would tie to Tie::Static::Hash, etc. In fact I am still unsure whether it is better to always tie to Tie::Static, or to tie to the actual package that you are blessed into. There is something to be said for a consistent interface. There is also something to be said for not violating expectations about what tied is.

As for the examples you offer of broken ties, read the first paragraph of "bugs". While it does not offer your examples, it is clear about the fact that the heuristic uses package, filename, and line number. Do you think it is clear enough to warn people away from that map trick?

Personally I am inclined to believe that someone who wants many tied variables will generally just tie a hash. Do you think that is wrong? Would it make sense to offer a function that takes a list of variables and ties them? Something like this?

sub static { my $called = join ":", caller(); tie ($_[$_], 'Tie::Static', $called, $_) for 0..$#_; }
Then people can just call:
static my ($foo, $bar, $baz);
Yes? No? Maybe?

In reply to Re (tilly) 2: Tie::Static by tilly
in thread Tie::Static by tilly

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.