>>>>> "sw" == shawn wilson <ag4ve...@gmail.com> writes:

please learn how to quote emails properly. it is hard to tell here what
i replied and what you wrote. 

  sw> On Fri, Mar 18, 2011 at 4:50 PM, Uri Guttman <u...@stemsystems.com> wrote:
  >> >>>>> "sw" == shawn wilson <ag4ve...@gmail.com> writes:
  >> 
  sw> i ran across a peace of interesting code:
  sw> my $writer = shift->(
  sw> [ 200, [ "Content-type" => "text/plain" ], $s ]
  sw> );
  >> 
  >> first off, there is no OO anywhere in that code. all it is is a
  >> dereference of a code reference passed in to a sub.
  >> 
  >> 
  sw> [snip]

  sw> there is NO method there so it isn't a method call. if you have a code
  >> reference (to a regular sub) in $code then you dereference it like this:
  >> 
  >> $code->( args ... ) ;
  >> 
  >> all the code does is skip assigning the code ref from @_ into $code. i
  >> generally avoid that style of directly using the shift in an
  >> expression. it is better style to store it in a variable so you have
  >> some extra names to describe what that value is.
  >> 
  >> 
  >> so, what your saying is:
  sw> my $writer = sub {
  sw>  my $a = shift;
  sw>  return [ 200, [ "Content-type" => "text/plain" ], $s ];
  sw> }

no. where is the use of $a? where is the code call that dereferences the
ref?

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to