Re: Module Proposal: Parse::Reversible

2007-04-25 Thread Andy Armstrong
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 25 Apr 2007, at 21:18, Paul LeoNerd Evans wrote: I'm still inviting comment on its behaviour though... I like it. After "This regexp should not contain any capture brackets ( ) as these will confuse the parsing logic." I'd add "Instead use

Re: Module Proposal: Parse::Reversible

2007-04-25 Thread Paul LeoNerd Evans
On Wed, 25 Apr 2007 13:44:11 -0500 "David Nicol" <[EMAIL PROTECTED]> wrote: > has anyone mentioned "xeger" yet in this discussion? Not heard of that, no.. And it's unfortunately a little late now, behold: http://search.cpan.org/~pevans/String-MatchInterpolate-0.01/ An initial version :) I'm

Re: Module Proposal: Parse::Reversible

2007-04-25 Thread David Nicol
has anyone mentioned "xeger" yet in this discussion?

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread Paul LeoNerd Evans
On Tue, 24 Apr 2007 14:20:40 -0400 (EDT) "Daniel T. Staal" <[EMAIL PROTECTED]> wrote: > How about Text::Transform::ReversiblePattern ? > > Or even just Text::ReversiblePattern ? > > Daniel T. Staal I am tempted by that, but I would prefer it in the String:: space; as A. Pagaltzis points out bel

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread Daniel T. Staal
On Tue, April 24, 2007 11:05 am, Paul LeoNerd Evans said: > On Tue, Apr 24, 2007 at 04:01:10PM +0100, Andy Armstrong wrote: >> Text::Transform::Reversible ? > > "Transform" is too generic.. text goes in, other text goes out... That > doesn't capture the essence of pattern matching (no pun intended

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread A. Pagaltzis
* Paul LeoNerd Evans <[EMAIL PROTECTED]> [2007-04-24 19:40]: > Also, String::Template sounds too much like Text::Template, > which it isn't really.. It's a totally different idea. Not to me. “Text” to means a document (or some arbitrarily small unit of a document) that has meaning to a human. A “S

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread Paul LeoNerd Evans
On Tue, Apr 24, 2007 at 07:30:56PM +0200, A. Pagaltzis wrote: > I don’t know what it means for something to “sound like a > namespace.” :-) > > Also, I think of templates as generally reversible anyway. > Think of printf/scanf, strftime/strptime, URI::Template, > etc. String templates often go bot

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread A. Pagaltzis
* Andy Armstrong <[EMAIL PROTECTED]> [2007-04-24 19:15]: > String::Template::Reversible maybe? String::Template sounds > like a namespace rather than a module. I don’t know what it means for something to “sound like a namespace.” :-) Also, I think of templates as generally reversible anyway. Thin

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread Andy Armstrong
On 24 Apr 2007, at 18:07, A. Pagaltzis wrote: So I think somewhere under either Text:: or String:: might be better. String::Template? String::Template::Reversible maybe? String::Template sounds like a namespace rather than a module. -- Andy Armstrong, hexten.net

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread A. Pagaltzis
* Paul LeoNerd Evans <[EMAIL PROTECTED]> [2007-04-24 14:35]: > It's not just parsing, it's not just interpolation. It's both. > To name it after one of these operations ignores the other. > > So I think somewhere under either Text:: or String:: might be > better. String::Template? Regards, -- A

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread Paul LeoNerd Evans
On Tue, Apr 24, 2007 at 04:01:10PM +0100, Andy Armstrong wrote: > Text::Transform::Reversible ? "Transform" is too generic.. text goes in, other text goes out... That doesn't capture the essence of pattern matching (no pun intended :) ). -- Paul "LeoNerd" Evans [EMAIL PROTECTED] ICQ# 4135350

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread Andy Armstrong
On 24 Apr 2007, at 15:18, Sébastien Aperghis-Tramoni wrote: If the main objects your module will manipulate still are URIs, maybe it should be in the URI:: namespace. And couldn't the bidirectional relation you want to create be seen like a mapping? Hence URI::Mapper or something similar?

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread Paul LeoNerd Evans
On Tue, Apr 24, 2007 at 04:18:11PM +0200, Sébastien Aperghis-Tramoni wrote: > If the main objects your module will manipulate still are URIs, maybe > it should be in the URI:: namespace. And couldn't the bidirectional > relation you want to create be seen like a mapping? Hence URI::Mapper >

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread Sébastien Aperghis-Tramoni
Paul LeoNerd Evans wrote: No, I think at this point we have to appeal to the core reason for creating this module in the first place; namely, that it is bidirectional. Parsing a string into variables, or interpolating the variables back into a string. Both can be done within one object, symmetri

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread Paul LeoNerd Evans
On Tue, Apr 24, 2007 at 01:31:02PM +0100, Paul LeoNerd Evans wrote: > String::ParsableInterpolable > > Surely we can do better than that? Actually, I'm not even sure on the "parsable" part now. Parsing would imply some sort of possibly-recursive, context-aware grammar system. This is much simpl

Re: Module Proposal: Parse::Reversible

2007-04-24 Thread Paul LeoNerd Evans
On Fri, Apr 20, 2007 at 06:50:03PM +0100, Paul LeoNerd Evans wrote: > package Parse::Reversable; I'm suddenly not so sure on the name any more... It's not just parsing, it's not just interpolation. It's both. To name it after one of these operations ignores the other. So I think somewhere under

Re: Module Proposal: Parse::Reversible

2007-04-22 Thread A. Pagaltzis
* Paul LeoNerd Evans <[EMAIL PROTECTED]> [2007-04-21 15:00]: > Theirs don't have the regexp matches like mine, but I guess > that could always be done after the components have been pulled > out. (Also the implementation is a bit less efficient, but that > can be neatened up). I think of URIs as s

Re: Module Proposal: Parse::Reversible

2007-04-22 Thread Paul LeoNerd Evans
On Fri, 20 Apr 2007 21:26:33 +0100 Andy Armstrong <[EMAIL PROTECTED]> wrote: > I agree that it's not massively general - but you could use it to > > * generate fixed width fields > * truncate reals to ints > * specify the number of decimal places On further thought, that all sounds very specific

Re: Module Proposal: Parse::Reversible

2007-04-21 Thread Andy Armstrong
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 21 Apr 2007, at 13:57, Paul LeoNerd Evans wrote: Hmm.. Decisions... Do I change my code to use URI::Template, or release Parse::Reversible anyway, on the grounds that it does cover a slightly different area, even if in my case they're both usabl

Re: Module Proposal: Parse::Reversible

2007-04-21 Thread Paul LeoNerd Evans
On Sat, 21 Apr 2007 01:09:51 +0200 "A. Pagaltzis" <[EMAIL PROTECTED]> wrote: > * Paul LeoNerd Evans <[EMAIL PROTECTED]> [2007-04-20 19:55]: > > The requirement for this module came about intially because I > > was thinking about how to handle virtual URLs in websites > > It’s called “URI template

Re: Module Proposal: Parse::Reversible

2007-04-20 Thread Andy Armstrong
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20 Apr 2007, at 22:44, Paul LeoNerd Evans wrote: if only that, what happens if we want a literal : in our pattern - do we need to escape it? Or maybe to make it look more like a pattern, we might try ${NAME/pattern/format} Yup, or you coul

Re: Module Proposal: Parse::Reversible

2007-04-20 Thread A. Pagaltzis
* Paul LeoNerd Evans <[EMAIL PROTECTED]> [2007-04-20 19:55]: > The requirement for this module came about intially because I > was thinking about how to handle virtual URLs in websites It’s called “URI templates”, has an IETF draft RFC and there’s a tentative implementation already on the CPAN. R

Re: Module Proposal: Parse::Reversible

2007-04-20 Thread Paul LeoNerd Evans
On Fri, 20 Apr 2007 21:26:33 +0100 Andy Armstrong <[EMAIL PROTECTED]> wrote: > > An interesting idea, but what does that buy you that a plain > > sprintf does > > not? > > > > $pr->build( { ALBUM => sprintf("%04d", $album), > > PHOTO => sprintf("%04d", $photo) } ) > > It encap

Re: Module Proposal: Parse::Reversible

2007-04-20 Thread Andy Armstrong
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20 Apr 2007, at 20:23, Paul LeoNerd Evans wrote: An interesting idea, but what does that buy you that a plain sprintf does not? $pr->build( { ALBUM => sprintf("%04d", $album), PHOTO => sprintf("%04d", $photo) } ) It encapsul

Re: Module Proposal: Parse::Reversible

2007-04-20 Thread Paul LeoNerd Evans
On Fri, 20 Apr 2007 18:55:56 +0100 Andy Armstrong <[EMAIL PROTECTED]> wrote: > could optionally be > >'/photos/album${ALBUM:\d+:%04d}/photo${PHOTO:\d+:%04d}.jpg' > > to get back strings like > >'/photos/album0123/photo0001.jpg' An interesting idea, but what does that buy you that a pla

Re: Module Proposal: Parse::Reversible

2007-04-20 Thread Paul LeoNerd Evans
On Fri, 20 Apr 2007 11:25:48 -0700 "Joshua ben Jore" <[EMAIL PROTECTED]> wrote: > This is just named capturing, isn't it? In perl 5.10: > > qr!/photos/album(?\d+)/photo(?\d+).jpg!; > $url = "/photos/album$+{ALBUM}/photo$+{PHOTO}.jpg"; Oh, it's that and more. It's a named capture, sure. But i

Re: Module Proposal: Parse::Reversible

2007-04-20 Thread Joshua ben Jore
On 4/20/07, Paul LeoNerd Evans <[EMAIL PROTECTED]> wrote: The requirement for this module came about intially because I was thinking about how to handle virtual URLs in websites; for example: /photos/album12/photo17.jpg This will fetch the 17th photo from the 12th album, by whatever method in

Re: Module Proposal: Parse::Reversible

2007-04-20 Thread Andy Armstrong
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20 Apr 2007, at 18:50, Paul LeoNerd Evans wrote: I'd appreciate some comments on this; specifically, if this functionallity would be useful enough to put on CPAN, or if it seems a quite specialised solution to a specific problem and not worth doin

Module Proposal: Parse::Reversible

2007-04-20 Thread Paul LeoNerd Evans
The requirement for this module came about intially because I was thinking about how to handle virtual URLs in websites; for example: /photos/album12/photo17.jpg This will fetch the 17th photo from the 12th album, by whatever method internally is used. Internally, we need to know these values.