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

  uri> please keep the various things clear. the original code you
  uri> posted (without the surrounding sub) was not OO, nor a closure,
  uri> nor an event handler. your original question was about shift->()
  uri> and only that.
  >> don't
  uri> keep wandering around all these other things until you fully get what
  uri> that was. i still am not sure if you got it as each of your rewrites
  >> was
  uri> off target. the outer context and closure stuff came in but i never
  >> saw
  uri> you grasp the code dereferenced concept or syntax. you kept saying OO
  uri> when it wasn't OO.

  sw> yes, it's not oo anything - i get that. from my last response:
  sw> he shifts $_[ 0 ]; into that last closure. what happens to that value? why
  sw> not just:
  sw> return sub{ [ 200, [ "Content-type" => "text/plain" ], $s ] };

again, you are confusing two different issues. please stop that as it
is slowing down your learning perl. the shift->() is a pure syntax
issue. the closure wasn't even IN THE CODE you first posted. they are
separate things and should be addressed separately.

here is your original post to refresh your memory:

***********************

i ran across a peace of interesting code:

my $writer = shift->(
 [ 200, [ "Content-type" => "text/plain" ], $s ]
);

so, if i understand this correctly, this would be the same as
my $writer = sub {
 my $a = shift;
 my $thing = sub {
  my $subthing = $writer->{ $a };
  return  [ 200, [ "Content-type" => "text/plain" ], $subthing ];
 }
}

***********************

the first part has no closure, no OO, nothing but a simple code
dereference with a shift making it more obscure. you claimed to rewrite
it (but it seems you quoted more code context) and that has a closure
and much more complex code. that is why you are always jumping
around. did you ask about the dereference? why bring up the closure but
you never asked about that in the beginning. stick to one topic at a
time.

  sw> so, i'm still curious why:
  sw> my $ref = shift;
  sw> my $writer = $ref->{ [ 200, [ "Content-type" => "text/plain" ], $s ] };

  sw> why is writer defined to that $ref with those variables? why not
  sw> just define $writer? or better yet, just 'return' the array? as it
  sw> is, you'd have to dereference $writer in order to access anything
  sw> in that index. i just don't get that.

oy. look at the code i pasted from you. look carefully at the char
following the shift->. what is that char? what is the char following
$ref-> in your above code? are they the same? if not, what is the
difference?

as i keep saying, you haven't learned the basics of code references and
dereferencing. stick to that topic BEFORE you get into closures. why?
because closures are independent of that and they are more
complex. master one concept before you jump to another. you are not
learning here, you are just splashing around in a kiddie pool.

now address the code dereference issue. drop all the others for
now. learn this first. learn it well. then move on. 

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