Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: pcre callouts



On Mon, Oct 30, 2023 at 5:04 PM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> So, e.g. (?C{foo}) or (?C'foo') will call the foo function. In Perl,
> $_ is set to the string being examined. I've used .pcre.subject. Would
> something else be better

You could actually use ${.pcre._} I suppose.  I'm undecided on whether
that's better.

> and should it perhaps start and end a new scope
> to make that local?

We do have a precedent for that now with ${|...} creating a scope.

> This won't do anything for numeric callouts. They look mostly useful for
> debugging. They could perhaps call a standard function passing the
> number and string as parameters.

What's an example of using a number callout outside of zsh?

I see you're calling parse_string() here:

> +    if (!block->callout_number &&
> +           ((prog = parse_string((char *) block->callout_string, 0))))

How are you solving the problem of finding the end of the callout?
That is, (?C{code}) looks like it would have the same parsing problems
I wrestled with for ${|code}.  Is it just that you can skip everything
from "(?" to the matching ")" without having to worry about
(un)balanced braces inside, etc.?




Messages sorted by: Reverse Date, Date, Thread, Author