On Thu, Mar 24, 2011 at 4:42 PM, Rob Dixon wrote:
>
> On 24/03/2011 02:39, Peter Scott wrote:
>>
>> On Tue, 22 Mar 2011 13:41:59 -0700, Randal L. Schwartz wrote:
>>
>>> "Peter" == Peter Scott writes:
my $s = Streamer->new;
my $app = sub {
return sub {
$s->open_fh;
my
On 24/03/2011 02:39, Peter Scott wrote:
On Tue, 22 Mar 2011 13:41:59 -0700, Randal L. Schwartz wrote:
"Peter" == Peter Scott writes:
my $s = Streamer->new;
my $app = sub {
return sub {
$s->open_fh;
my $writer = shift->(
[ 200, [ "Content-type" => "text/plain" ], $s ] );
};
};
Peter> As i
On Tue, 22 Mar 2011 13:41:59 -0700, Randal L. Schwartz wrote:
>> "Peter" == Peter Scott writes:
>
>>> my $s = Streamer->new;
>>> my $app = sub {
>>> return sub {
>>> $s->open_fh;
>>> my $writer = shift->(
>>> [ 200, [ "Content-type" => "text/plain" ], $s ] );
>>> };
>>> };
>
> Peter> As it
On Fri, Mar 18, 2011 at 5:34 PM, shawn wilson wrote:
> sorry, i don't know how to do any better in gmail (and does it different on
> the gmail app on my android too - sorta messed up). should i color replies
> differently or something?
Quoting is typically done by prefixing each line of the quote
You still seem a bit confused so lets try to start over straight
to the point:
On Fri, Mar 18, 2011 at 4:31 PM, shawn wilson wrote:
> i ran across a peace of interesting code:
>
> my $writer = shift->(
> [ 200, [ "Content-type" => "text/plain" ], $s ]
> );
To understand just this piece of code,
> "sw" == shawn wilson writes:
sw> I learned a new way to use shift here (or probably any function
sw> that uses $_) and I have (sorta learned about closures.
you are doing it again. $_ and @_ have nothing to do with each
other. and shift never touches $_. shift works on its array argume
On Mar 22, 2011 4:43 PM, "Randal L. Schwartz" wrote:
>
> > "Peter" == Peter Scott writes:
>
> >> my $s = Streamer->new;
> >> my $app = sub {
> >> return sub {
> >> $s->open_fh;
> >> my $writer = shift->(
> >> [ 200, [ "Content-type" => "text/plain" ], $s ]
> >> );
> >> };
> >> };
>
> Peter> A
> "Peter" == Peter Scott writes:
>> my $s = Streamer->new;
>> my $app = sub {
>> return sub {
>> $s->open_fh;
>> my $writer = shift->(
>> [ 200, [ "Content-type" => "text/plain" ], $s ]
>> );
>> };
>> };
Peter> As it stands, this doesn't make sense because nothing happens to
$writer;
Peter
> "sw" == shawn wilson 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 wanderi
On Sat, Mar 19, 2011 at 10:46 PM, Uri Guttman wrote:
> > "sw" == shawn wilson 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" == shawn wilson 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 (general
thank you all. i have a much better grasp on what this means now. at least i
know why i had trouble with it - i didn't (don't) understand closures. and,
i am not used to event driven programming. the example comes from psgi which
(generally) gets an event and gives you data. i've also been looking
On Fri, 18 Mar 2011 17:34:00 -0400, shawn wilson wrote:
> here's the whole function (i didn't think i needed to post it because i
> get the rest of this code):
Your problem is less to do with Perl than it is with explaining what you
need clearly. Clear thinking and clear communication lead to cl
> "sw" == shawn wilson writes:
sw> On Fri, Mar 18, 2011 at 7:02 PM, Shawn H Corey
wrote:
>> my sub_ref = shift @_;
>> my $writer = $sub_ref->(
>> [ 200, [ "Content-type" => "text/plain" ], $s ]
>> );
sw> oh, that's right, i forgot the general oo use of:
sw> my( $self, @etc )
On Fri, Mar 18, 2011 at 7:02 PM, Shawn H Corey wrote:
> On 11-03-18 06:41 PM, shawn wilson wrote:
>
>> an argument to what sub?
>> (it's obvious that i've missed the boat on this concept)
>>
>
> my $writer = shift->(
>[ 200, [ "Content-type" => "text/plain" ], $s ]
>);
>
> The
On 11-03-18 06:41 PM, shawn wilson wrote:
an argument to what sub?
(it's obvious that i've missed the boat on this concept)
my $writer = shift->(
[ 200, [ "Content-type" => "text/plain" ], $s ]
);
The array @_ contains a sub ref as its first argument. It is this sub
that
On Fri, Mar 18, 2011 at 6:36 PM, Shawn H Corey wrote:
> On 11-03-18 06:21 PM, shawn wilson wrote:
>
>> my $a = Streamer->new;
>> my $app = sub {
>> return [ 200, [ "Content-type" => "text/plain" ], $a->open_fh ];
>> }
>>
>> ... i think, but a part of me is thinking that if it were that simple, i
On 11-03-18 06:21 PM, shawn wilson wrote:
my $a = Streamer->new;
my $app = sub {
return [ 200, [ "Content-type" => "text/plain" ], $a->open_fh ];
}
... i think, but a part of me is thinking that if it were that simple, it
would have written like that (bad reasoning for thinking i'm wrong, but
On Fri, Mar 18, 2011 at 6:21 PM, shawn wilson wrote:
>
>
> On Fri, Mar 18, 2011 at 5:45 PM, Uri Guttman wrote:
>
>> > "sw" == shawn wilson writes:
>>
>>
>> sw> On Fri, Mar 18, 2011 at 5:23 PM, Uri Guttman
>> wrote:
>> >> > "sw" == shawn wilson writes:
>>
>>
> ok, taking another crac
On Fri, Mar 18, 2011 at 5:45 PM, Uri Guttman wrote:
> > "sw" == shawn wilson writes:
>
>
> sw> On Fri, Mar 18, 2011 at 5:23 PM, Uri Guttman
> wrote:
> >> > "sw" == shawn wilson writes:
> >> >>
> >> >> so, what your saying is:
> >>
> sw> my $writer = sub {
> sw> my $a = shift;
>
> "sw" == shawn wilson writes:
sw> On Fri, Mar 18, 2011 at 5:23 PM, Uri Guttman wrote:
>> > "sw" == shawn wilson writes:
>>
>> please learn how to quote emails properly. it is hard to tell here what
>> i replied and what you wrote.
>>
>> sorry, i don't know how to do any
On Fri, Mar 18, 2011 at 5:23 PM, Uri Guttman wrote:
> > "sw" == shawn wilson writes:
>
> please learn how to quote emails properly. it is hard to tell here what
> i replied and what you wrote.
>
> sorry, i don't know how to do any better in gmail (and does it different on
the gmail app on my
> "SHC" == Shawn H Corey writes:
SHC> On 11-03-18 04:31 PM, shawn wilson wrote:
>> my $writer = shift->(
>> [ 200, [ "Content-type" => "text/plain" ], $s ]
>> );
SHC> shift will shift @_ in a sub and @ARGV outside of one. So the first
SHC> question is this inside a sub or not?
On 11-03-18 05:05 PM, shawn wilson wrote:
my $writer = sub {
my $a = shift;
return [ 200, [ "Content-type" => "text/plain" ], $s ];
}
Try:
$sub_ref = shift @_;
my $writer = $subref->( [ 200, [ "Content-type" => "text/plain" ], $s ] );
The shift is shifting @_; it should be written as:
> "sw" == shawn wilson 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 wrote:
>> > "sw" == shawn wilson writes:
>>
sw> i ran across a peace of interesting code:
sw
On Fri, Mar 18, 2011 at 4:51 PM, Shawn H Corey wrote:
> On 11-03-18 04:31 PM, shawn wilson wrote:
>
>> my $writer = shift->(
>> [ 200, [ "Content-type" => "text/plain" ], $s ]
>> );
>>
>
> shift will shift @_ in a sub and @ARGV outside of one. So the first
> question is this inside a sub or not
On Fri, Mar 18, 2011 at 4:50 PM, Uri Guttman wrote:
> > "sw" == shawn wilson 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 i
On 11-03-18 04:31 PM, shawn wilson wrote:
my $writer = shift->(
[ 200, [ "Content-type" => "text/plain" ], $s ]
);
shift will shift @_ in a sub and @ARGV outside of one. So the first
question is this inside a sub or not?
The first item in the array (@_ or @ARGV) has to be a reference to
> "sw" == shawn wilson 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
29 matches
Mail list logo