On Tue, 22 Aug 2023 18:45:44 +0000 Oodler 577 via perl5-porters <perl5-porters@perl.org> wrote: > > I wonder if you are not aware of the keyword plugging system, > > available since 5.14? > > It's used extensively by modules like List::Keywords and > > Object::Pad as ways to prototype new functionality that could > > eventually be brought into core (and indeed some of it has been, > > e.g. via Corinna). > > Thank you, we had not looked at this but will. It's very powerful; particularly as exposed by XS::Parse::Keyword and in some cases XS::Parse::Sublike. With it I've been able to implement: * async/await syntax https://metacpan.org/pod/Future::AsyncAwait * real object syntax https://metacpan.org/pod/Object::Pad * real try/catch syntax (that became core's feature 'try') https://metacpan.org/pod/Syntax::Keyword::Try * real match/case syntax https://metacpan.org/pod/Syntax::Keyword::Match All of these things are in use right now today in various real systems, real companies actually using this lot for real production work. They all play together, because they're not silly "lets rewrite the source code with a regexp" trickery; they're properly integrated into the parser in a properly reëntrant way. E.g. observe the way you can put a match/case inside a try/catch block in an `async method` of a class. Of particular note I want to draw attention to the fact that combining `async` from Future::AsyncAwait and `method` from Object::Pad works just fine despite the fact that neither module knows about the other. When I wrote about programming languages being like Lego sets, this is precisely the sort of thing I mean. In addition at Perl v5.38 we added another mechanism for defining new infix operators; so now while we're getting rid of smartmatch we can continue to experiment with better replacements for it. https://metacpan.org/pod/Syntax::Operator::Equ https://metacpan.org/pod/Syntax::Operator::Identical https://metacpan.org/pod/Syntax::Operator::Matches and again - these all play together just fine. You can use an `equ` or `=:=` operator inside match/case inside try/catch inside ... I think my point is clear here. These are the core-supported mechanisms we've been using for the past decade to experiment with new syntax and new ideas that we eventually bring into the core language. -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/Thread Previous | Thread Next