drieuxster (drieuxster) wrote,
drieuxster
drieuxster

yes, I would probably opt for passing by hash ref, but...

Out there in GOD hating Land, we have
considering revenge on everyone who creates "functions" in perl that pass arguments via hashes. such BRAIN DAMAGE is intolerable.
Which is at times a reasonable attack on the folly of a listIn/listOut system. Especially one that will
allow for 'fat comma', the game of doing
my @gotBack = thisFunction( type => 'a', addr => '192.168.231.4', verb => 'add' )
Which is slightly better than the sort of Love that one gets with signatures like
void furBall( string recordType, string ip_addr, string verb)
Where they are all just strings, and of course inevitably some dilbert implements that as
try {
this.furBall('add', 'a', '192.168.231.4');
} catch(excpetion e) ...
and then spends some time trying to sort out why they did not get what they expected... Yes kids, that scrawdelous can be done massively elegantly in a variety of badly implemented coding languages.

But then again, as I suggested, I would probably do the fun of passing by reference, hence my code would have been
my @gotBack = thisFunction({ type => 'a', addr => '192.168.231.4', verb => 'add' } )
But realistically they should have understood that I probably would have done that in some sort of perlish object, and would of course opted to throw an exception if there was an issue so it would most likely have been say
my @gotBack = eval {
$obj->thisFunction({ type => 'a', addr => '192.168.231.4', verb => 'add' } ) };
if ( $EVAL_ERROR ) {
...
but that way of course leads into the DANGER of actually tossing up, in the carp, die, what ever, an object, vice a mere string, and that way gets into complicated techical stuff. ( did I mention the part about 'use english' - oh well, yes, of course you already knew about that piece of technical knowledge as well... )

Now why is the drieux passing by reference to a hash rather than the fat comma folly? Because by passing by reference I only push one argument onto the stack to call the function, vice the six that would be needed to implement the fat comma solution. All of which reminds us of the most important of all religious commitments:
Every Stack Frame Is Sacred....
So realistically the big up side to passing by hash, ref or fat comma, is that IF the API is really still in flux, which most of them are, till they have some history, the need to ultimately 'improve' by allowing 'but what if we need widgetFlagSnoovelBlark?' then you point out in the next release that in fact one can pass in 'widgetFlagSnoovelBlark => true' and all of the previous code still works, since of course inside of the function, method, what ever, the existence of a widgetFlagSnoovelBlark is left piously in the hands of functionally agnostic, but clearly fullly committed to the TRUE MORAL PIETY, since of course, as we all know:
Every Stack Frame Is Sacred....
And only the demonic coder would ever do anything badder....
Subscribe
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments