Terrence,
On Nov 23, 2004, at 5:40 PM, Terrence Brannon wrote:
��� It would be neat if there were some method-chaining syntax/module which
��� indicated "return false if your method call returns false":
������ $object-?->method1-?->method2-?->method3
This reminds me of some of the REBOL built-ins which had the :
func
func:
func?call syntax. I dont recall the details of them off the top of my head however, but that is irrelevant anyway.
This is an interesting idea, but I have a one questions about it. How would you know which method failed? Just returning a false value does not tell me anything other than the whole method chain failed, which might be okay for plain old code, but would be difficult to deal with during debugging.
Also, I think it might be more interesting if you were to allow different types of boolean logic, maybe like this:
$object-&&->method()-||->method2()-&&->method3();
Of course then we get into precendence order and allowing for grouping and such. It could get really messy, so maybe thats not such a good idea.
Personally I do stuff like this with exceptions. If my whole chain works, then all is well, if something happens in the middle somewhere, then an exception is thrown and I deal with appropriately. Utilizing stack traces from my exceptions I get excellent debugging info as well to pinpoint the failure location.
Steve
_______________________________________________ sw-design mailing list [EMAIL PROTECTED] http://metaperl.com/cgi-bin/mailman/listinfo/sw-design
