I disagree. Tied variables are a great way to create objects that look and feel like standard Perl variables but that change their behaviours in interesting and useful ways. It's true that most of the time you'll want people to use the "traditional" interfaces, but there will be a small number of cases where the things you want to do fall outside of that interface. I don't see that as an argument for throwing away the simpler interface completely.

Did you see my recent article at perl.com about tied hashes? There's an example in there of a hash with a fixed set of keys. When you tie the hash, you pass it a list of the valid keys. Most of the time you can then use the tied object as a normal hash. It's possible, however, that you might want to change the set of valid keys at some point in the application. There's no way to achieve that with the hash interface so you need to invent new object methods (note: Tie::Hash:FixedKeys doesn't do this yet, but I've been thinking of adding it). Most people will never need to use these functions, so I really don't want to make it harder for them to use the object by recasting it as a more traditional object class.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you don't talk about Perl club."


In reply to Re: Re: Tied variables and functions for them by davorg
in thread Tied variables and functions for them by japhy

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.