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

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

by ysth (Canon)
on Nov 29, 2004 at 07:16 UTC ( [id://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 <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!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2024-04-19 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found