Skip Menu |

This queue is for tickets about the Class-Std CPAN distribution.

Report information
The Basics
Id: 14343
Status: new
Priority: 0/
Queue: Class-Std

People
Owner: Nobody in particular
Requestors: dan.kubb-cpan [...] autopilotmarketing.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.0.4
Fixed in: (no value)



Subject: New CHAIN method attribute
I was wondering what you thought about an addition to Class::Std. The CUMULATIVE tag allows you to get the results from every method in the inheritance tree, as if you had called all of them individually. I propose a CHAIN tag that performs similarly, but instead it should pass the results of one method call into the next, forming sort of a pipeline of methods. A common pattern is to use NEXT like so: sub my_method { my ($self, @args) = @_; # do something with @args return $self->NEXT::my_method(@args); } In the above case my_method may delegate to another "parent's" my_method all the way up the chain.. the results of the parent's call are passed down to the child in a chain until the final results are returned to the caller. I'd like something that performs the same basic task, but like this: sub my_method : CHAIN { my ($self, @args) = @_; # do something with @args return @args; } This would call all the methods bottom-up, and CHAIN(BASE FIRST) would go bottom-up the same way CUMULATIVE(BASE FIRST) does. This would replace the other common NEXT pattern: sub my_method { my ($self, @args) = @_; @args = $self->NEXT::my_method(@args); # do something with @args return @args; } With: sub my_method : CHAIN(BASE FIRST) { my ($self, @args) = @_; # do something with @args return @args; } The reason for this is that I see these as two of the most used NEXT patterns, especially in classes that use NEXT heavly -- a prime example being Catalyst, which used NEXT exactly in this manner. If you don't like the name CHAIN other possible names might be FILTER, PIPELINE or PIPE. Let me know if you like the idea, as I'd be happy to submit a patch that allows this.
Date: Mon, 29 Aug 2005 06:22:26 +1000
From: Damian Conway <damian [...] conway.org>
To: bug-Class-Std [...] rt.cpan.org
Subject: Re: [cpan #14343] New CHAIN method attribute
RT-Send-Cc:
Show quoted text
> I was wondering what you thought about a [:CHAIN] addition to Class::Std.
I think it's an excellent idea and would welcome a patch. The only suggestions I'd have are that the feature: 1. should be :CHAINED, not :CHAIN 2. must be careful to preserve call context (list vs scalar) Go to it! Damian
Subject: :CHAINED patch
From: dan.kubb-cpan [...] autopilotmarketing.com
Attached is a patch that adds the :CHAINED attribute to Class::Std. It includes the actual code changes, additional documentation and a new test case. I was unsure of the status of other patches, such as those to add runtime load-ability to Class::Std classes, so this patch should be applied to the CPAN version of Class::Std 0.0.4. Let me know if you'd like any changes or additions made to the patch.

Message body is not shown because it is too large.

[DKUBB - Mon Aug 29 02:41:09 2005]: Show quoted text
> Let me know if you'd like any changes or additions made to the patch.
I have looked at this patch and there seems to be a bit of confusion as to the directions for traversing the class hierarchy. My impression is that the default direction is from the top of the class downward - meaning from the base class down through the child classes. The direction called 'BASE FIRST' is the opposite - traversing from the child classes up through the parents. The term 'BASE' in 'BASE FIRST' seems to be the source of the confusion. My impression is that it does not refer to base class (i.e., the top of the class hierarchy), but to the the classes at the bottom of the class hierarchy, i.e., the children that form the base. If this is correct, then the directions in your patch need to be reversed.
[JDHEDDEN - Wed Nov 2 19:53:20 2005]: Show quoted text
> [DKUBB - Mon Aug 29 02:41:09 2005]:
> > Let me know if you'd like any changes or additions made to the
> patch. > > I have looked at this patch and there seems to be a bit of confusion > as to the directions for traversing the class hierarchy.
After further research, I find that the confusion is on my part, and that 'BASE FIRST' means from base classes downward. So the :CHAINED patch is consistent.