Author: larry Date: Tue May 29 12:03:39 2007 New Revision: 14406 Modified: doc/trunk/design/syn/S12.pod
Log: Allow closures as indirect methods as suggested by blazer++ Modified: doc/trunk/design/syn/S12.pod ============================================================================== --- doc/trunk/design/syn/S12.pod (original) +++ doc/trunk/design/syn/S12.pod Tue May 29 12:03:39 2007 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 27 Oct 2004 - Last Modified: 21 May 2007 + Last Modified: 29 May 2007 Number: 12 - Version: 52 + Version: 53 =head1 Overview @@ -222,6 +222,18 @@ $obj.$methodname(1,2,3) +The variable may contain either the name of a method or a closure +object. In the latter case the closure is called with the object +as its first argument, so that a closure may be used to abstract a +"navigational" path through a data structure without specifying the +root of the path till later. + + $locator = -> $root, $x, $y { $root.<foo>[$x]<bar>{$y}[3] } + $obj.$locator(42,"baz") # $obj<foo>[42]<bar><baz>[3] + + $locator = { .<here> } + $obj.$locator # $obj<here> + The method name may also be quoted with either single or double quotes: $obj."$methodname"(1,2,3) # same as previous