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.
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:
(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.