Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I wasn't being sarcastic about using the call_onobj function. I wouldn't have written that specific set of function calls because I don't use Gtk2. I used something similar in some code just yesterday. This is off the top of my head and I didn't use your specific function but it did the same sort of thing. In my case I'm effectively generating my functions and parameters by parsing a file and returning a list of events and parameters for them. It so happens that the general technique of writing your function calls as data is really convenient when parsing stuff. I can take one pass over the data to get my list of events and then just execute the events as code.

call_onobj( $renderer, [ 'UseFont', 0 ], [ 'SetDots', 52 ], [ 'SetScanLines', 300 ], [ 'AdjustDots', 15 ], [ 'AdjustScanLines', 2 ], [ 'Text', 'This is some text to be added to the output ] );

The original query was on a series of hardcoded method calls all onto the same object. This is more general because now the method calls are mutable as data. It benefits two ways - by being more powerful and by not being a mimic for an unrelated sort of thing. I read $obj->UseFont( 0 )->SetDots( 52 )->SetScanLines( 300 )->AdjustDots( 15 )->AdjustScanLines( 2 )->Text( '...' ) as more likely to be a deep object access than anything else. In general, I suspect that I will continue to be surprised when someone writes the preceding and they are all really just successive method calls on the $obj object. I grant that some uses of whitespace can make the chained-self intent more visible to someone who expects that. I don't think it helps anyone who didn't already have this technique in mind. I also think that no only I not be helped, that I will be hindered. The technique with this syntax is a dead end in perl5 and I would like it for people to write concise, clear code without it.


In reply to Re^3: Mutator chaining considered harmful by diotalevi
in thread Mutator chaining considered harmful by Aristotle

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!
  • 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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (6)
    As of 2015-07-06 08:59 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (70 votes), past polls