Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matching function type parameters #572

Open
lyleunderwood opened this issue Nov 4, 2024 · 0 comments
Open

Matching function type parameters #572

lyleunderwood opened this issue Nov 4, 2024 · 0 comments

Comments

@lyleunderwood
Copy link

Forgive me, I'm new to gritql.

I'm trying to write a pattern that matches functions regardless of whether or not they have type parameters.

First of all, this seems like it should be a pretty common use case and I kinda feel like there should be a pattern for this in the standard library, but I'll be damned if I can find any reasonable way to find things in there. I found these and this seems like the place where this kind of utility would go, and these kinds of utilities seem like they would be super useful to have (useful abstractions over basic complexities of a workflow built on top of an AST), but it really feels like they should be made more visible via documentation somewhere.

Second, I can match against a function_declaration AST node just fine to solve my problem, but I couldn't find any way using the pattern syntax to match a function with type parameters.

I tried the following:

`function $funcname <$t1>($args) {$body}`
`function $funcname $t1($args) {$body}`
`function $funcname $...($args) {$body}`
`function $...($args) {$body}`

(I still don't really understand what $... does...)

I went to the docs and looked at the "Syntax Reference" which is just incredibly frustrating because it is in reality just a cheat sheet, and not at all a comprehensive technical reference for the language syntax. I understand why having a cheat sheet here is nice to ease people into using gritql, but when you are really trying to dig into the language like I am, you need to be able to go to an explicit syntax reference. Otherwise I'm just trying to reverse-engineer the language syntax in the studio application (which is pretty slick). If there is a reference somewhere, it's not visible enough.

Anyway, let me know if there's an obvious way that I've missed to accomplish this, and I hope that some of this feedback on documentation is useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant