chumsky icon indicating copy to clipboard operation
chumsky copied to clipboard

custom() is unusable due to Stream method privacy

Open jvanstraten opened this issue 2 years ago • 3 comments

As far as I can tell, custom() is currently completely unusable because all methods that manipulate a Stream are merely pub(crate), and thus cannot be used from application code.

jvanstraten avatar Jun 13 '22 16:06 jvanstraten

This is true. I've so far avoided exposing details of Stream's API because it's quite complicated and I don't want to develop the crate into a corner.

I'm aiming to reveal more aspects of the crate's internals in the zero-copy branch (probably subsets of internal APIs, to allow the implementation to continue evolving more flexibly), such that it might be more useful.

zesterer avatar Jun 13 '22 16:06 zesterer

Makes sense. It definitely seems like a "don't touch if you don't know what you're doing" thing, and I understand the maintenance aspects of exposing internals like that. It's a bit weird that it exists at all when it can't (yet) be used, though. I don't know if you intend to release before zero-copy is done (not sure how far along it is), but if so, maybe a deprecation and a note in the docs about this is in order at some point?

jvanstraten avatar Jun 13 '22 17:06 jvanstraten

It's a bit weird that it exists at all

custom came into existence very early in the crate's life when it wasn't yet clear to me which direction it would move in. I initially thought that dropping down to custom would be quite a common thing to need to do but, thankfully, this turned out to not be the case for almost all applications. I would have removed it earlier if not for a few minor cases where it might be desirable for have something like it in the future.

I don't know if you intend to release before zero-copy is done

There are several unreleased changes on master, so I will probably be doing one more 0.x release before the merge of zero-copy, but I want to delay this until zero-copy is looking like it's almost ready to avoid having master be effectively deprecated for a long window of time.

zesterer avatar Jun 13 '22 17:06 zesterer

zero-copy makes custom useful by exposing many of InputRef's methods publicly: not as fully-featured as implementing Parser by hand, but definitely enough to do some funky stuff like writing regex parsers.

zesterer avatar Feb 20 '23 22:02 zesterer