Carl (>>), Aaron (>): >> * Grammars define a hierarchical structure that seems to be perfect >> for encoding the packing of larger pieces of data, for example when >> serializing an object structure. Could one use grammars, or something >> very much like it, as a "modern" &pack template? > > A while back we had a fairly productive conversation about matching regexes > on non-textual data: > http://groups.google.com/group/perl.perl6.language/msg/24f23fdfc0c5d459?hl=en
Interesting thread. > My proposal there is incomplete, but matching structured data (even if that > structure is just a sequence of non-textual bytes) using rules definitely > makes sense to me. The real question is: what is the least invasive way to > do it? Modifying nqp for this purpose would, I think, not make sense. I > think we'd need a pure Perl implementation of the rules engine that could > match either text or data, and that's a gigantic undertaking. Crazy people have been known to implement the rules engine in Perl 6, even... :-) But I think we can get away much cheaper than that. If we contend ourselves with keeping an early sublanguage inside strings, or with some well-chosen subroutine names, we could experiment with hierarchical matchers today in Rakudo. I'd love for someone to develop a proof-of-concept module for something like this; both matching on binary data, and the hierarchy matcher described in your thread. In fact, jnthn++ had a talk at YAPC::EU the other week where he showed how nested signatures can be used to make hierarchical matches. A proof-of-concept module could simply be some sugar around this already existing functionality. // Carl