Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

does detach cancel forward

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


rippls at woodlandschools

Nov 2, 2009, 8:52 AM

Post #1 of 11 (1918 views)
Permalink
does detach cancel forward

Hi all.

I'm building "chains" of methods using forward and detach mostly, I
quote the chains because I know it's not the regular chained methods but
my "chains" vary according to where you are etc. Anyway, the question I
have is whether forward is still valid after a detach... let me
illustrate...

If A forwards to B, once B is done it comes back to A, that I use and it
works. If C detaches to D to doesn't come back after D, again I use
that.

Now, If from A I forward to B, then B detaches to C which detaches to D,
it doesn't seem to come back to A after D. Is this my mistake
somewhere, is it by design? Does the detach after a forward "cancel"
the forward?

Thanks,
Steve


--
Steve Rippl
Technology Director
Woodland Public Schools
360 225 9451 x326

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


publiustemp-catalyst at yahoo

Nov 4, 2009, 2:19 PM

Post #2 of 11 (1827 views)
Permalink
Re: does detach cancel forward [In reply to]

----- Original Message ----

> From: Steve Rippl <rippls [at] woodlandschools>
>
> I'm building "chains" of methods using forward and detach mostly, I
> quote the chains because I know it's not the regular chained methods but
> my "chains" vary according to where you are etc. Anyway, the question I
> have is whether forward is still valid after a detach... let me
> illustrate...
>
> If A forwards to B, once B is done it comes back to A, that I use and it
> works. If C detaches to D to doesn't come back after D, again I use
> that.
>
> Now, If from A I forward to B, then B detaches to C which detaches to D,
> it doesn't seem to come back to A after D. Is this my mistake
> somewhere, is it by design? Does the detach after a forward "cancel"
> the forward?

Think of detach as "game over", if that helps (probably doesn't). From the docs, detach(....) is described as:

The same as forward, but doesn't return to the previous action when processing is finished.

I think that description might be a bit confusing for some, as your question suggests.

Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://use.perl.org/~Ovid/journal/
Twitter - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6



_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


davewood at gmx

Nov 7, 2009, 12:52 AM

Post #3 of 11 (1807 views)
Permalink
Re: does detach cancel forward [In reply to]

>From the new Catalyst Book:

"$c->forward returns to the calling action and ompletes the request,
while $c->detach proceeds to the end action after the called actions
are completed."


On Wed, Nov 4, 2009 at 11:19 PM, Ovid <publiustemp-catalyst [at] yahoo> wrote:
> ----- Original Message ----
>
>> From: Steve Rippl <rippls [at] woodlandschools>
>>
>> I'm building "chains" of methods using forward and detach mostly, I
>> quote the chains because I know it's not the regular chained methods but
>> my "chains" vary according to where you are etc.  Anyway, the question I
>> have is whether forward is still valid after a detach... let me
>> illustrate...
>>
>> If A forwards to B, once B is done it comes back to A, that I use and it
>> works.  If C detaches to D to doesn't come back after D, again I use
>> that.
>>
>> Now, If from A I forward to B, then B detaches to C which detaches to D,
>> it doesn't seem to come back to A after D.  Is this my mistake
>> somewhere, is it by design?  Does the detach after a forward "cancel"
>> the forward?
>
> Think of detach as "game over", if that helps (probably doesn't).  From the docs, detach(....) is described as:
>
>    The same as forward, but doesn't return to the previous action when processing is finished.
>
> I think that description might be a bit confusing for some, as your question suggests.
>
> Cheers,
> Ovid
> --
> Buy the book         - http://www.oreilly.com/catalog/perlhks/
> Tech blog            - http://use.perl.org/~Ovid/journal/
> Twitter              - http://twitter.com/OvidPerl
> Official Perl 6 Wiki - http://www.perlfoundation.org/perl6
>
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>



--
David Schmidt | http://www.fm5.at

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


andrew at cleverdomain

Nov 7, 2009, 1:07 AM

Post #4 of 11 (1801 views)
Permalink
Re: does detach cancel forward [In reply to]

On Wednesday 04 November 2009 04:19:42 pm Ovid wrote:
> Think of detach as "game over", if that helps (probably doesn't). From the
> docs, detach(....) is described as:
>
> The same as forward, but doesn't return to the previous action when
> processing is finished.
>
> I think that description might be a bit confusing for some, as your
> question suggests.
>

Yeah, there are at least two big shortcomings.

1. I think that we should stop trying to over-simplify things here, or at
least stop *only* providing a simplified version and tell the truth: detach
forwards, and then it throws an exception. That exception propagates up until
the whole stack of running actions is unwound, and then Catalyst catches it
and continues processing as usual, calling any 'end' action and then doing
'finalize'.

2. There's a "Flow Control" section in Catalyst::Manual::Intro that paints a
better picture than perldoc Catalyst, but someone going directly to the docs
for forward, detach, etc. can easily miss the pointers to
Catalyst::Manual::Intro. The whole Manual::Intro business is a mess that
nobody wants to touch. I don't know what to do with it either. :)

Andrew

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


rippls at woodlandschools

Nov 7, 2009, 11:08 AM

Post #5 of 11 (1793 views)
Permalink
Re: does detach cancel forward [In reply to]

On Sat, 2009-11-07 at 01:07 -0800, Andrew Rodland wrote:
> Yeah, there are at least two big shortcomings.
>
> 1. I think that we should stop trying to over-simplify things here, or
> at
> least stop *only* providing a simplified version and tell the truth:
> detach
> forwards, and then it throws an exception. That exception propagates
> up until
> the whole stack of running actions is unwound, and then Catalyst
> catches it
> and continues processing as usual, calling any 'end' action and then
> doing
> 'finalize'.
>
> 2. There's a "Flow Control" section in Catalyst::Manual::Intro that
> paints a
> better picture than perldoc Catalyst, but someone going directly to
> the docs
> for forward, detach, etc. can easily miss the pointers to
> Catalyst::Manual::Intro. The whole Manual::Intro business is a mess
> that
> nobody wants to touch. I don't know what to do with it either. :)
>
As the noob that started all this I would say that the docs I came
across (the online tutorial and the books) are pretty clear on what the
effects of forward and detach are, it's just that I had started thinking
in terms of "nested" flow control because that's what I wanted (wishful
thinking...). I thought perhaps each forward created a separate
nest/level I could detach out of and previous forwards were
"remembered", but obviously this isn't the case. Maybe just something
stating that this flow control is "flat" in some sense, each control
statement has no notion of previous ones...

Anyway, thanks to you all for straightening me out!

Steve


--
Steve Rippl
Technology Director
Woodland Public Schools
360 225 9451 x326

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


moseley at hank

Nov 7, 2009, 12:55 PM

Post #6 of 11 (1787 views)
Permalink
Re: does detach cancel forward [In reply to]

On Sat, Nov 7, 2009 at 11:08 AM, Steve Rippl <rippls [at] woodlandschools>wrote:

>
> As the noob that started all this I would say that the docs I came
> across (the online tutorial and the books) are pretty clear on what the
> effects of forward and detach are, it's just that I had started thinking
> in terms of "nested" flow control because that's what I wanted (wishful
> thinking...). I thought perhaps each forward created a separate
> nest/level I could detach out of and previous forwards were
> "remembered", but obviously this isn't the case. Maybe just something
> stating that this flow control is "flat" in some sense, each control
> statement has no notion of previous ones...
>


eval { }


--
Bill Moseley
moseley [at] hank


rippls at woodlandschools

Nov 7, 2009, 2:28 PM

Post #7 of 11 (1797 views)
Permalink
Re: does detach cancel forward [In reply to]

On Sat, 2009-11-07 at 12:55 -0800, Bill Moseley wrote:
>
>
> On Sat, Nov 7, 2009 at 11:08 AM, Steve Rippl
> <rippls [at] woodlandschools> wrote:
>
>
> As the noob that started all this I would say that the docs I
> came
> across (the online tutorial and the books) are pretty clear on
> what the
> effects of forward and detach are, it's just that I had
> started thinking
> in terms of "nested" flow control because that's what I wanted
> (wishful
> thinking...). I thought perhaps each forward created a
> separate
> nest/level I could detach out of and previous forwards were
> "remembered", but obviously this isn't the case. Maybe just
> something
> stating that this flow control is "flat" in some sense, each
> control
> statement has no notion of previous ones...
>
>
> eval { }
>

Well that works, thanks!!


andrew at cleverdomain

Nov 7, 2009, 3:30 PM

Post #8 of 11 (1774 views)
Permalink
Re: does detach cancel forward [In reply to]

On Saturday 07 November 2009 01:08:33 pm Steve Rippl wrote:
> it's just that I had started thinking
> in terms of "nested" flow control because that's what I wanted (wishful
> thinking...). I thought perhaps each forward created a separate
> nest/level I could detach out of and previous forwards were
> "remembered", but obviously this isn't the case.

No, this *is* the case, 100%. Forward is nothing more than a function call, so
you can nest it and you get a call stack. It's just that, as I pointed out,
detach throws an extension that unwinds that whole stack.

Andrew

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


rippls at woodlandschools

Nov 7, 2009, 3:44 PM

Post #9 of 11 (1787 views)
Permalink
Re: does detach cancel forward [In reply to]

On Sat, 2009-11-07 at 15:30 -0800, Andrew Rodland wrote:
> On Saturday 07 November 2009 01:08:33 pm Steve Rippl wrote:
> > it's just that I had started thinking
> > in terms of "nested" flow control because that's what I wanted
> (wishful
> > thinking...). I thought perhaps each forward created a separate
> > nest/level I could detach out of and previous forwards were
> > "remembered", but obviously this isn't the case.
>
> No, this *is* the case, 100%. Forward is nothing more than a function
> call, so
> you can nest it and you get a call stack. It's just that, as I pointed
> out,
> detach throws an extension that unwinds that whole stack.
>
Sorry I wasn't clear, I got that it worked that way with forward, what
threw me was I didn't assume that detach unwound the whole stack (until
I saw it behaving that way). But if I put use eval{$c->forward...) as
Bill suggested then a detach within that gets me back to where I want to
be. I could probably rework things and remove the detaches I have in
there and just rely on the appropriate forwards, but the eval{} is a
quick solution.

Thanks for clarifying...

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


pagaltzis at gmx

Nov 7, 2009, 11:54 PM

Post #10 of 11 (1765 views)
Permalink
Re: does detach cancel forward [In reply to]

* Steve Rippl <rippls [at] woodlandschools> [2009-11-08 00:55]:
> But if I put use eval{$c->forward...) as Bill suggested then
> a detach within that gets me back to where I want to be.
> I could probably rework things and remove the detaches I have
> in there and just rely on the appropriate forwards, but the
> eval{} is a quick solution.

It sounds like maybe you are actually looking for Chained
dispatch. If you can illustrate what you are trying to do with
some (pseudo-)code, me or someone else could show an equivalent
structure using Chained; if it fits the problem you’re trying to
solve it’ll likely be cleaner.

Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


andrew at cleverdomain

Nov 8, 2009, 12:02 AM

Post #11 of 11 (1759 views)
Permalink
Re: does detach cancel forward [In reply to]

On Saturday 07 November 2009 05:30:27 pm Andrew Rodland wrote:
> out, detach throws an extension that unwinds that whole stack.

Being tired makes me type words that *sound* similar to the one I meant.
Exception. Not extension. Exception. :)

Andrew

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.