Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Comment on

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

I guess I'm trying to make my code (modules) easier to use for both myself and others; if the the method is used incorrectly, and the program when runs tells me 'hey don't do that, you should use me in this and that way' it would cut down substantially on my debugging hours...

But it's quite true that as soon as your code works, the whole checking becomes quite useless...

Invoking the methods would still work exactly the same way, but if the 'modifiers' indicate that the method 'expects' a certain kind of first argument (be it class, object or either), the method could check to see if that's ok, and if not, croak.

Almost every way of using the methods would still work. The only thing that might not, would be 'borrowing' methods from other modules/classes without using inheritancy. But I can't help feeling that doing something like that indicates a design flaw anyway...

So yes, I would like to have the option to have Perl behave a bit like some other language... But then again, aren't most good things based in part on a collection of other good things? If I remember correctly, Larry was using sed and awk, but needed more... So he invented Perl and borrowed a bunch of the functionality from those tools amongst others. Which is great! I love it!

It's not like I'm saying "Hey Perl should change, and everyone should do this!"... But traversing @ISA, and the UNIVERSAL class seem to be considered standard perl, and you are allowed, not obliged to use them... I would think being allowed (but not obliged) to use features such as the modifiers I suggested would further extend the freedom a Perl programmer has to build 'mean & clean' OO code...

Everyone seems to be asking "Why do you want to be able to do this?"... Well, I would ask "Why would you not want to be able to do this?". Right now I'm doing it manually anyway... :)

So either I'm just not getting what the 'evilness' is in my idea (even though I read every reply at least twice), or I just don't agree... :)


In reply to Re: Re: OO-style modifiers for 'sub' ? by Gilimanjaro
in thread OO-style modifiers for 'sub' ? by Gilimanjaro

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
  • Outside of code tags, you may need to use entities for some characters:
            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: (15)
    As of 2014-09-22 18:30 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (198 votes), past polls