emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make peg.el a built-in library?


From: Stefan Monnier
Subject: Re: Make peg.el a built-in library?
Date: Fri, 01 Oct 2021 23:57:56 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Eric Abrahamsen [2021-10-01 11:40:47] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> In org-ql, the PEX is redefined at load time and/or run time, being
>>> derived from search keywords that are defined by the package and
>>> possibly by the user.  So the PEX can't be defined in advance, at
>>> compile time.  So having to use `with-peg-rules' means having to use
>>> `eval'.
>>
>> If the grammar changes radically at run time, based on external/user
>> data there's probably no better way than via `eval` or similar (`load`,
>> `byte-compile`, you name it).
>
> Can you explain why a function plus some sort of pre-compilation step
> won't work?

That "function plus precompilation step" would do the equivalent of
`eval` ;-)

> I suppose the `call' pex you mentioned up-thread could also ease things
> a bit.

Indeed, with it you can define a function like `peg-and` such that

    (peg-and (peg PEX1) (peg PEX2))   ===    (peg (and PEX1 PEX2))  

but using such functions to build a PEG would result in substantially
slower code (because it gets split into many small functions, thus
increasing the function call overheads).


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]