Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: (tye)Re4: ref, no, maybe?

by jlp (Friar)
on Jan 11, 2001 at 07:01 UTC ( #51065=note: print w/replies, xml ) Need Help??

in reply to (tye)Re4: ref, no, maybe?
in thread ref, no, maybe?

As the author of this hypothetical function, i take the stance that it is Not My Problem(tm). My flawless (haha!) docs clearly state that the function can take a plain scalar or a hashref; not a hash-based object. I contend that the burden falls on the you, the caller, to put the data in the condition my function expects.

Now if Perl doesn't provide a good way for you to do that, that is another argument entirely.

Replies are listed 'Best First'.
(tye)Re6: ref, no, maybe?
by tye (Sage) on Jan 11, 2001 at 10:30 UTC

    "I object! Your honor, to use the 'It's documented so it isn't a bug' defense, the defendant also has to document why the 'bug' wasn't just 'fixed'." ;-)

    So do you write "I'm too lazy to use UNIVERSAL::isa() -- too many keystrokes"? "I have a religious and/or philosophical objection to object implementations using my module"?

    If your documentation says "hash ref" and not "hash ref that isn't blessed", then not handling a "blessed hash ref" (which is, by the way, still a "hash ref") is a violation of your own documentation. q-:

    If your documentation says "an unblessed hash ref", then I have to ask "Why??". Are you now going to start checking tied(%$self) and croaking if the reference is to a tied hash? Is there some problem with using UNIVERSAL::isa()? A very simple change makes your module more useful. Is there some down side to this? I don't see one. I didn't see you mention one. What is your objection to this?

    And there are other cases that your theoretical module "breaks". For example, Win32::TieRegistry exposes the Win32 "Registry" as a huge hash of hashes. So the majority of things that you'd want to do can be done by just dealing with a huge hash of hashes. But for a few advanced options, the reference to this huge virtual hash of hashes is also blessed into a package so you can use it directly to make method calls.

    So it really sucks when a module, for example, to search down a hash of hashes searching for something (kind of like File::Find for hash trees) can't be used on this hash of hashes that I did all this work to make available to millions of Win32 Perl users.

    There you made me say it. Happy now?

            - tye (but my friends call me "Tye")

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (1)
As of 2023-06-05 00:54 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (22 votes). Check out past polls.