Ok, in this thread tilly was wondering why I had to pass my args via reference. Here is why:

We had a homegrown DBI here and the boss mandated that we swap it out in place of DBI. However, all existing code had to work without changes. So far, so good. However, we also had to make a feature extension. Before, when calling stored procedures, there was no way to pass in a set of scalars to be modified as OUT parameters. So stored procs could only be called with IN parms.

So, the whole idea was before people would do:

my $retval = $sth->exec_sp($val1, $val2);
And the only way to extend this with functionality for dealing with new OUT parms without breaking any existing code was to "earmark" one of the scalars. And the best way to do that is for that scalar to be an array ref. Thus to make a call to a stored proc and expect OUT parms to be bound is now:
my $retval = $sth->exec_sp($val1, $val2, [ \($outval1, $outval2) ]);
So, then all I do is run through @_ and splice out any scalar which is an array ref and consider those values as the ones to do a DBI bind_param_inout() on.

Ok, so now my earlier unexplained software engineering rationale is now explained.

2001-04-15 Edit by Corion : Moved to Meditations


In reply to Non-invasive API extension by use of array refs by princepawn

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.