On Mon, Feb 8, 2021 at 5:49 PM Dave Mitchell <davem@iabyn.com> wrote: > To give an example (one of many): perl's peephole optimiser is hookable; > both for the top-level call which "peepholes" an entire optree, but also > at the recursion level: you can hook each time Perl_rpeep() is called to > follow along an alternative execution path as found in LOGOPs etc. > > It's documented - people are told it's there and they can use it, but its > not documented in terms of what perl promises as regards how and when it > will recurse. So people will write XS modules using it based on "what perl > does at the moment". So if perl's behaviour changes, the behaviour of the > XS code may change. > > At a trivial level, suppose I want to fix the peephole optimiser in some > way to avoid deeply recursing (and so avoid crashing the stack on deeply > nested and perhaps auto-generated code like A ? B : C ? D : E ....). > Now the fix is harder because I may be changing where and how often the > rpeep hook is called and thus triggering lots of BBC reports for CPAN > modules I've now broken. Or more generally, if in the future I want do to > Brave New World stuff to do with perl compiling - e.g. separate out op > chains into Basic Blocks for better optimisation, or translate to LLVM or > bytecode or whatever - its an albatross around my neck. > > Hooks give people the illusion of flexibility and being able to expand > perl in exciting, modern, and dynamic new ways; in reality it's a further > nail in the coffin. I think that there are two factors at play here: cost and benefit. IMO the actual decision should be decided not by either of them individually, but their ratio. I don't think that was how we made this sort of decision in the past (often the cost was ignored entirely). As for this particular change, I'm optimistic about the benefit, but rather pessimistic about the cost (not just because precedence and associativity have to be handled correctly, but also because having a tokenizer/parser split makes this extra difficult). I'm not sure where that leaves us. LeonThread Previous | Thread Next