Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: The Null Mull (or, when OO needs more O)

by ysth (Canon)
on Nov 29, 2004 at 07:16 UTC ( #410873=note: print w/replies, xml ) Need Help??

in reply to The Null Mull (or, when OO needs more O)

You seem to be missing something that I've seen in every other implementation of this: something to make the result false when a method is no longer being called on it, via overload. So that:

my $obj = Foo::->new->set_bar("iron")->inc_baz(1000)
   or die "something in there went horribly wrong: ", $obj->errmsg;
$obj or die "something in there went horribly wrong: ", $obj->errmsg;
(Updated to fix nit picked by ihb)

can trigger the error clause. But I'm not a big fan of this method of working anyway; when I've had to chain lots of methods (usually only when using B), I just wrap the whole chain in an eval block.

Replies are listed 'Best First'.
Re^2: The Null Mull (or, when OO needs more O)
by brian_d_foy (Abbot) on Nov 29, 2004 at 08:13 UTC

    I left out the overload stuff on purpose. I didn't want to get into it because it's just one way of doing things, and the recipe is not a concept. If someone gets the idea, they can implement the other stuff so it fits into how the rest of the system does things. I'd much rather see people use a consistent metaphor rather than cobble together different styles.

    The Gang of Four, or any other designs pattern book, is not a cookbook ;)

    brian d foy <>
Re^2: The Null Mull (or, when OO needs more O) (d'tor die)
by tye (Sage) on Nov 29, 2004 at 18:41 UTC

    I'd also have it die if it gets destroyed w/o anyone having asked it whether it failed or what the failure reason was. Otherwise, $obj->this()->that()->other(); can silently break.

    - tye        

Re^2: The Null Mull (or, when OO needs more O)
by ihb (Deacon) on Nov 29, 2004 at 17:52 UTC

    Nitpick: you have to have die in another statement if you want to do that.


    See perltoc if you don't know which perldoc to read!
    Read argumentation in its context!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://410873]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2018-02-24 20:19 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (310 votes). Check out past polls.