On Mon, Mar 22, 2021 at 2:50 PM yary <not....@gmail.com> wrote: > > how to get all nested captures worked for me ... not sure I agree with the > design
I think the current flattening aspect is awkward in a couple ways: * Having to specify `<top=$regex>`. I half like Brad's suggestion. * Having to write `<top>.pairs` to extract the captures. Are your reservations about the design related to the above awkwardnesses? I can see scope for improvement on the above in years to come. Some other commentary: For regexing, it makes sense to return single match objects or flat lists. Devs can then manually add structure to those results if they wish. For parsing, it makes sense to go the other way around, returning nested structures that devs can manually flatten if they wish (as I did). For data structures in general, for some tasks, it makes sense to flatten by default and let devs add structure if they wish, and for other tasks it makes sense to maintain structure by default and let devs flatten if they wish. A PL does have to pick one or the other, either on a general basis, or on a feature-by-feature basis. Perl generally focused on the flat-by-default approach, with regexes fitting in that scheme, and has stayed true to its roots, albeit with some evolution toward improvements for structured data in recent years as devs have contributed additions to the language. Raku generally focused on the structured-data-by-default approach. It also unified regexes and parsing. The natural outcome was a bias toward structure (parse trees). I anticipate there will be improvements for flattening structured data as time passes. -- love raiph