Idiomatic? I think pretty much all of the above are idiomatic to some degree. However, the simple case in the OP is idiomatic to any API, whether Perl, C, Java, or other. The concept is simple: we're renaming a function, but we don't want to break old code, so we'll provide a forwarding function which will call the new function automatically. In Java, this is often combined with some Javadoc that says it's @deprecated - code that is already compiled against the deprecated function will continue to work, new code trying to be compiled against it will get a warning during compilation.

The exact syntax to get this behaviour is quite idiomatic to Perl, but what it's trying to do is common across many languages.

As to your new example, that, too, is idiomatic to OO languages. The precise syntax, of course, is again Perlish. But the concept (the idiom) is common to OO languages everywhere - one object "HASA" second object. When I myfoot->press( mycar->get_accelerator() ) ... then a series of actions happen:

sub Foot::press { shift; shift->press(@_); } sub Accelerator::press { my $self = shift; my $fuel_amount = $self->convert_pressure_to_liters(@_); $self->get_car()->get_engineblock()->burn_more_fuel($fuel_amount); }
This may be written in perlish pseudo-code, but it applies the same to any other language.


In reply to Re^3: One line accessor method style. by Tanktalus
in thread One line accessor method style. by Anonymous Monk

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.