(Yet) another attempt of extensions syntax #9219
Unanswered
mharthoorn
asked this question in
Language Ideas
Replies: 1 comment 1 reply
-
See: #8916 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Mads in hist latest talk (NDC London) showed of Extensions and the struggle over the years to find the right syntax. Since there were a lot of questions and some push back, I was wondering if that was also caused by that these syntax patterns deviate from existing C# patterns. In some cases that's necessary, but it can also make C# as a language less intuitive and harder to learn.
In the case of extensions, we should be able to use existing patterns more than is done in the latest proposal, without it becoming artificial. So here goes yet another attempt that also tries to reduce boiler plate like the current proposal. Hopefully opening up some new perspectives, at least.
Patterns taken from:
Note that i use
this
here to align with existing extension methods. Personally I thinkbase
might be an even better keyword.This of course does not exclude the option of having the type declared at the root if all extensions are on the same type:
But also here new syntax is not required. Existing syntax should do fine.
Beta Was this translation helpful? Give feedback.
All reactions