Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

djberg96 (2603)

djberg96
  (email not shown publicly)

Journal of djberg96 (2603)

Thursday March 14, 2002
02:30 PM

See Want.pm

[ #3520 ]
Ok, a conversation came up in pdcawley's journal, and I thought I should share something with y'all as most people don't seem to know about it.

Basically, the topic centered around whether or not to always return $self (for method chaining) or a value (for, say, an lvalue).

With Want, by Robin Houston (robin), you can distinguish based on calling context. So, for example, you can tell the difference between these:

$obj->method1;

$obj->method1->method2;

$val = $obj->method;

myFunc($obj->method);

Want can do much more than this (eg rvalue subs, etc), but I find the "want('OBJECT')" call to be the most useful. :)

Enjoy!

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.