Skip to main content


. @leonerd

I saw your post here about extensible syntax <https://www.nntp.perl.org/group/perl.perl5.porters/2024/03/msg268067.html> and mentioned it to the #PDL team because we have a module called NiceSlice that implements a variable postfix syntax using a source filter. This obviously has problems for complex code.

We'd like something more robust and were wondering if you had any thoughts about ways we could not use a source filter and still get this working (in a lexical scope of course).

#perl

in reply to Zaki

The syntax added by that module looks very weird and subtle; hard to imagine how to add that robustly at all.

Reliable methods are keyword-based, with a leading keyword. See the kinds of things that can be made by XS::Parse::Keyword - https://metacpan.org/pod/XS::Parse::Keyword

Or perhaps as an infix operator with XS::Parse::Infix, on perl 5.38 onwards.
https://metacpan.org/pod/XS::Parse::Infix
This may or maynot be plausible though, depending on how the surrounding behaviour is supposed to operate.

in reply to Paul Evans

I see. Yeah, I agree it is very subtle especially with expressions inside. Currently the approach is to used `Text::Balanced`, but that can't take into account the surroundings.

2 things we were thinking:

1. Some way to use the `$var->[ index ]` syntax like with NumPy.

2. Trying to look at `tree-sitter-perl` and how it can be extended with this syntax to figure out any ambiguities.