4 ms·
Not really. First argument (the object you are extending) needs to be marked with `this`, which is an annotation.
by stanac 3y ago
Not really. First argument (the object you are extending) needs to be marked with `this`, which is an annotation.
- hardware2win 3y agoEhh, ive been talking about whole lang and ecosystem But I agree about "this" being similar concept
- whizzter 3y agoThere are tons of annotations over the hood. The "this" that GP mentions is for for extension methods similar to the article to be regcognizeed as such (never done if the annotation isn't present), they're written such as: static int Foo( this Bar bar, int biz) => bar.xyz+biz; Bar bar = new Bar() { xyz=123; }; int result = bar.Foo(456); // Works even if Foo wasn't a part of Bar initially Elsewhere annotations(called attributes in C# land) can often be used in the same way as in Java to document serialization behaviour,etc. So in practice there aren't much differences apart from how library authors haven't embraced it entirely as much for automagic bindings (partly due to philosophy, partly due to other facilities being more appropriate).
- dtech 3y agoThere is a massive difference between a feature universally offered by the language and something only supported by using a specific library of compiler plugin...
- dtech 3y agoWhat a weird take. Parent obviously meant @X meta-programming annotations, not language syntax and keywords with a specific definition. The definition that includes it is so broad that it loses all meaning, it would make "private", "class" or "boolean" also annotations.
- depoll 3y agoIn .net world, the C# "this" syntax is itself just syntactic sugar over an annotation (attribute in .net parlance): https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute?view=net-7.0 https://learn.microsoft.com/en-us/dotnet/api/system.runtime....
- nh23423fefe 3y agoofftopic: why is this link a broken redirect in chrome but not firefox?
- ElectricalUnion 3y agoMy guess is that MSDN POs prioritize testing with Blink/Edge WebView2 over other engines.