go ahead... be a heretic | |
PerlMonks |
Re: curried-up mooseby Jenda (Abbot) |
on Jan 21, 2009 at 23:42 UTC ( [id://737991]=note: print w/replies, xml ) | Need Help?? |
Waitasecond. Assuming you did not intend to say that the legs have some eyes, you want the $body->legs(...) to return the modified $body, right? So the $body->eyes will return the $body as well, right? So the $body->eyes->color returns the color of the body, not the color of the eyes, right? I guess not... So what does the $body->method(...) return? The modified $body or some inner object? Or sometimes one and sometimes the other? Method chaining works OK on objects that do not have any inner objects and whose method names make it very very clear which ones modify the object (and then return the modified $self) and which ones return some properties. As soon as it's not entirely clear, you're gonna run into problems. Maybe it would be better to use somethign like this instead: (This is similar to the with(object) { .method(...); .method(...) } of some languages.) It's kinda shame you can't use something like as that would be easy to write and I think it would not clash with anything.
In Section
Seekers of Perl Wisdom
|
|