http://www.perlmonks.org?node_id=410873


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 <bdfoy@cpan.org>
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.

    ihb

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