Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How to best pass on the context / wantarray?

by CountZero (Bishop)
on Mar 26, 2006 at 18:20 UTC ( #539303=note: print w/ replies, xml ) Need Help??


in reply to How to best pass on the context / wantarray?

I would be perfectly happy with the repeated code lines. When writing new methods, all you have to do is some quick copy and paste.

Adding a wrapper method strikes me as "cleverness for the sake of cleverness".

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law


Comment on Re: How to best pass on the context / wantarray?
Re^2: How to best pass on the context / wantarray?
by eric256 (Parson) on Mar 27, 2006 at 16:02 UTC

    "cleverness for the sake of cleverness".

    It might seem that way, until you find bug in those 8 lines and have to fix them everywhere you find them. cut-and-paste still yells "your doing something the hard way" to me. ;)


    ___________
    Eric Hodges
Re^2: How to best pass on the context / wantarray?
by BerntB (Deacon) on Mar 28, 2006 at 06:34 UTC
    I don't agree, since you blow up the size of the code. That makes it harder to work with quite often.

    I had a similar problem once with a hobby project (don't ask).

    There were states in a state engine, where the individual states were implemented as methods.

    At the start of all the state methods there were some admin code (to unpack parameters) and also when returning (the return values were data structure that told the management system what to do with the next state).

    The first part, the in parameter handling, became intolerable. Often the setup was half the code. I should have had some configuration that dynamically generated code, or munged the symbol table, or something.

    The ugly extra at the return values were ok. Didn't even look that bad, in the end.

    IMHO, what works best is a matter of taste, depending upon the code you add the extra lines to. (-: I would probably bet money that both you and Corion has better taste than me. :-)

      There is no accounting for taste!

      Strange enough I much like these (traditional) incantations at the beginning of subroutines and object-methods. It gives some kind of homely feeling.

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://539303]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2014-07-28 12:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (196 votes), past polls