Skip Menu |

This queue is for tickets about the DateTime-Format-Builder CPAN distribution.

Report information
The Basics
Id: 2427
Status: resolved
Priority: 0/
Queue: DateTime-Format-Builder

People
Owner: Nobody in particular
Requestors: perl [...] faerber.muc.de
Cc:
AdminCc:

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



Date: Tue, 22 Apr 2003 15:55:09 +0200
From: Claus Färber <perl [...] faerber.muc.de>
To: Iain Truskett <spoon [...] cpan.org>
Subject: [DateTime::Format::Parser] multiple callback functions & parameter passing (patch)
Hallo, I have a patch to DateTime::Format::Builder (0.62) that will add the following functionality: - preprocess, postprocess, on_*, will all take a coderef or arrayref (pointing to coderefs). this allows to do the following: @code = (\&code1, \%code2); $parser1 = { ..., postprocess => [ @code ], }; push @code, \&code3; $parser2 = { ..., postprocess => [ @code ], }; DateTime::Format::Builder->create_class( parsers => { 'p1'=>$parser1, 'p2'=>$parser2 }; This makes sense for more complex modules. (Yes, it will make a module I'm writing simpler.) - preprocess, postprocess, on_* will take two additinal parameters: 'self': allows accessing the parser object, possibly reading configuration parameters, e.g. from $class->new( 'european' => 1); 'param': arrayref to additional parameters passed to the parsing functions, e.g. from $p->parse_datetime('1/2/3', 'european' => 1); Tests and documentation are included. -- http://www.faerber.muc.de/

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

Subject: [DateTime::Format::Builder] multiple callback functions & parameter passing (patch)
[perl@faerber.muc.de - Tue Apr 22 18:12:00 2003]: Show quoted text
> I have a patch to DateTime::Format::Builder (0.62) that > will add the following functionality:
Show quoted text
> - preprocess, postprocess, on_*, will all take a coderef or arrayref > (pointing to coderefs).
Concept accepted but I'll be doing a different patch for it. I can see some ways to simplify some code (which will result in faster parser execution at the expense of slower class creation; the preferred trade-off). I also want to keep the simple case simple =) [...] Show quoted text
> This makes sense for more complex modules. (Yes, it will > make a module I'm writing simpler.)
The Postgres one? Show quoted text
> - preprocess, postprocess, on_* will take two additinal parameters:
Show quoted text
> 'self': allows accessing the parser object, possibly reading > configuration parameters, > e.g. from $class->new( 'european' => 1);
Sounds reasonable. Show quoted text
> 'param': arrayref to additional parameters passed to the > parsing functions, > e.g. from $p->parse_datetime('1/2/3', 'european' => 1);
So long as they're never mandatory =) Show quoted text
> Tests and documentation are included.
And will be incorporated =) Much obliged for this. Nice to see my stuff being used =) cheers, -- Iain.
Heyo. Checkout the CVS copy of Builder - the multiple callbacks thing has been added to that. Have a test. cheers, -- Iain.