-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
migrate Go func, func name, and lambda to treesitter #1756
Conversation
The previous definitions were mostly correct, although they were missing the possibility of declaring a function without a body. (Understandably. They are rare.) See the end of https://go.dev/ref/spec#Function_declarations.
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/go/changeFunkBat.yml
Outdated
Show resolved
Hide resolved
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/go/changeFunkBat2.yml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Still a couple open discussions but nothing that should stop this from merging
mark: {type: decoratedSymbol, symbolColor: default, character: b} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: _ = func() { /* body */ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow lambdas really do look similar to named functions in Go. I wonder if we should just make "funk" a superset of "lambda" in Go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that. I'll do it.
I would really like to set up a per-language docs page skeleton (#1642), so I can start adding notes to it as I go. I'm a bit concerned about the perfect (autogenerated! list of all scopes! etc.) being the enemy of the good here, and forgetting useful details along the way.
I'll mark this PR as to-discuss for that purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, with a simple test. If/when this merges, will update the wiki.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow lambdas really do look similar to named functions in Go. I wonder if we should just make "funk" a superset of "lambda" in Go
@AndreasArvidsson any objections to this one? Technically inconsistent with other languages but if you look at the syntax they're very similar to names functions
@josharian is it common to pass a short anonymous function directly as a function call arg? That's the main place where we prefer not to get trapped by "funk" in javascript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it common to pass a short anonymous function directly as a function call arg?
Not super common, but not rare either.
To my mind the most important aspect is that IMHO it is rare to be looking at a piece of code and not know whether it is in an anonymous func or not. It's a combination of syntax and usage. And typescript it is common for code in lambdas to outnumber the rest of the code by a significant factor, and to have that fact be relatively locally invisible.
There is long-standing discussion about adding more concise lambdas to the language, e.g. golang/go#21498. If that went in, I can definitely see the desire to use lambda
for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I don't feel super strongly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's hard to tell them apart I would be perfectly fine with supporting funk. It would be really irritating if you had to think about the syntax when using cursorless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool sounds like we're on the same page then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would really like to set up a per-language docs page skeleton (#1642), so I can start adding notes to it as I go. I'm a bit concerned about the perfect (autogenerated! list of all scopes! etc.) being the enemy of the good here, and forgetting useful details along the way.
I'll mark this PR as to-discuss for that purpose.
I'm not sure we should have this PR be to-discuss for that purpose, as that seems outside the scope of this PR. Prob better to mark that issue to-discuss and merge this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
The previous definitions were mostly correct,
although they were missing the possibility
of declaring a function without a body.
(Understandably. They are rare.)
See the end of https://go.dev/ref/spec#Function_declarations.
Checklist