TIMTOWTDI.

I think as long as an $obj->{attribute} is documented as part of the API it's fine to use it. Who am I to worry about the maintenance of a foreign module like DBI.

from DBI docs:

$h->{AttributeName} = ...; # set/write ... = $h->{AttributeName}; # get/read

But I'm open to hear from other CPAN modules besides DBI which "decapsulate" their internals.

I have colleagues who thought doing this with undocumented attributes which were only set in the constructor is fine. I disagree strongly.

That's like monkey patching a module or changing parts of a laptop, one shouldn't be surprised about loss of warranty.

> But all approaches that add another layer of indirection between the intention to set a value and the hash access make things slower.

Noteworthy that DBI is adding such a layer:

Attempting to set or get the value of an unknown attribute generates a warning

This will hardly be fast.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice


In reply to Re^4: Language design: direct attribute access and postponed mutators (Perl Vs Python) by LanX
in thread Language design: direct attribute access and postponed mutators (Perl Vs Python) by LanX

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.