On Sat, Mar 19, 2011 at 10:46 PM, Uri Guttman <u...@stemsystems.com> wrote:

> >>>>> "sw" == shawn wilson <ag4ve...@gmail.com> writes:
>
>   sw> thank you all. i have a much better grasp on what this means
>  sw> now. at least i know why i had trouble with it - i didn't (don't)
>  sw> understand closures. and, i am not used to event driven
>  sw> programming. the example comes from psgi which (generally) gets an
>  sw> event and gives you data. i've also been looking into anyevent
>  sw> (following the rabbit hole) to try to figure out event programming
>  sw> better. however, i see now that i need to take a few steps back
>  sw> and understand closures first.
>
> uri> please keep the various things clear. the original code you posted
> uri> (without the surrounding sub) was not OO, nor a closure, nor an event
> uri> handler. your original question was about shift->() 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.
>
>
>
yes, it's not oo anything - i get that. from my last response:
he shifts $_[ 0 ]; into that last closure. what happens to that value? why
not just:
return sub{ [ 200, [ "Content-type" => "text/plain" ], $s ] };

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

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

Reply via email to