Skip to content

Static anonymous functions #110886

Discussion options

You must be logged in to vote

I understand that this can be used as a hint for other developers. However, I find it hard to imagine a situation where it could be applied. Let’s assume the following scenarios:

I write an anonymous function that currently does not capture the context. As I understand, the compiler’s output will be the same whether I use the static keyword or not.
1. I do not use static. Time passes, another developer comes along, and they need to make changes to the method logic. Now a variable needs to be passed into the body, causing context capture. The code compiles, but performance issues may arise because the private class now contains non-static methods.
2. I used static, explicitly telling ever…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@sharpzilla
Comment options

@huoyaoyuan
Comment options

@En3Tho
Comment options

@CyrusNajmabadi
Comment options

Answer selected by sharpzilla
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants