[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 09b5f00613: ; Fix calls to treesit functions
From: |
Stefan Monnier |
Subject: |
Re: master 09b5f00613: ; Fix calls to treesit functions |
Date: |
Tue, 20 Dec 2022 10:35:16 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
>> I think this can be done simply by listing which functions are always
>> defined.
>
> No, this is not enough, IMO. What is needed in addition is to
> document how to know, with each of these always-defined functions,
> whether tree-sitter can be used (most probably, by examining the
> returned value).
That should be an obvious consequence of the behavior of the function
without needing to document it specifically.
Like with `treesit-parser-list`: if the list is empty, then it means we
don't have any parser at hand and that's it. If the callers additionally
needs to know whether it's because Tree-sitter is absent or for some
other reason, they'll need to call additional functions like
`treesit-available-p`.
>> Then we just have to make sure that those functions can be
>> implemented correctly even without Tree-sitter.
> The implementation without tree-sitter will probably be trivial, like
> return nil or something like that.
Yes, but for some functions this is not an option because we can't
provide a correct behavior without using Tree-sitter. So we have to
choose the set of always-defined functions based on whether they *can*
be correctly implemented without Tree-sitter.
`treesit-available-p`, `treesit-parser-list`, and `treesit-node-at` are
functions we can implement without Tree-sitter, because nil is already
the correct answer for those, without having to add any special
case in their docstring for that.
Stefan
- Re: master 09b5f00613: ; Fix calls to treesit functions, (continued)
- Re: master 09b5f00613: ; Fix calls to treesit functions, Stefan Monnier, 2022/12/19
- Re: master 09b5f00613: ; Fix calls to treesit functions, Theodor Thornhill, 2022/12/19
- Re: master 09b5f00613: ; Fix calls to treesit functions, Yuan Fu, 2022/12/19
- Re: master 09b5f00613: ; Fix calls to treesit functions, Eli Zaretskii, 2022/12/19
- Re: master 09b5f00613: ; Fix calls to treesit functions, Stefan Monnier, 2022/12/19
- Re: master 09b5f00613: ; Fix calls to treesit functions, Eli Zaretskii, 2022/12/20
- Re: master 09b5f00613: ; Fix calls to treesit functions,
Stefan Monnier <=
- Re: master 09b5f00613: ; Fix calls to treesit functions, Eli Zaretskii, 2022/12/20
- Re: master 09b5f00613: ; Fix calls to treesit functions, Stefan Monnier, 2022/12/20
- Re: master 09b5f00613: ; Fix calls to treesit functions, Yuan Fu, 2022/12/20