fn
arguments default to capturing
#484
Locked
mojodojodev
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Following up from this discord comment
For closures the default is that they're capturing, for someone learning the language this will surprise them with an error:
This is a really nice error but is there any way of matching the defaults when defining a
fn
with the defaults when defining afn
argument so this:Would expand to:
This would change the defaults so if you're marking a closure as
@noncapturing
you need to put the same tag in thefn
argument:If there is some important optimization for
fn
arguments defaulting to non-capturing, it would be good if defining a closure also defaults to@noncapturing
and you have to opt in to@capturing
, just so long as thefn
andfn
as an argument have the same defaults so users don't have to be introduced to the complexity straight away.Beta Was this translation helpful? Give feedback.
All reactions