Skip Menu |

This queue is for tickets about the POE CPAN distribution.

Report information
The Basics
Id: 8450
Status: resolved
Priority: 0/
Queue: POE

People
Owner: martijn [...] cpan.org
Requestors: martijn [...] cpan.org
Cc:
AdminCc:

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



Date: Tue, 16 Nov 2004 00:35:24 +0100
From: martijn [...] cpan.org
To: bug-poe [...] rt.cpan.org
Subject: patch for argument handling by POE::Session subclasses
The attached patch adds a method to POE::Session, which when implemented by subclasses gives them the chance to handle custom arguments they want to add to create() at the appropriate time.

Message body is not shown because sender requested not to inline it.

You explained that it's cleaner and faster to go with your patch, but I'm not convinced. The patch adds a bit of overhead to all session constructions, and it seems to perform the moral equivalent of sub create { my ($class, %params) = @_; # Validate and extract the subclass parameters. # Something like this, but maybe more optimal. my $param = delete $params{param} || croak "hey, you need a param"; # Create the session. my $self = bless $class->SUPER::create(@params), $class; # Plug the values into $self. $self->[WOOT] = $subclass_params{param}; # Return the object. Not that we care. return $self; }
We discussed this in IRC. Martijn said it was okay to close the ticket without applying the patch.
When I agreed the proposed solution was ok, I hadn't looked into this for a long time. Turns out it doesn't actually work for what I want, because I am overriding the _start event. I do this in try_alloc, which gets called during create because then the original _start event (if any) is available in a nicely managable form. So the reason for the patch which started this ticket is that I need these custom arguments at try_alloc() time, so before $class->SUPER::create is finished, and I couldn't store them in $self before $class->SUPER::create is finished