3 ms·
>And then C# has some questionable features (extension methods: methods for a class but that are not part of the class code). I dont think people share this op
by hardware2win 4y ago
>And then C# has some questionable features (extension methods: methods for a class but that are not part of the class code).
I dont think people share this opinion.
Extension methods are very handy and powerful while being simple and you can see how similar vision works well in Rust: impl trait for type
It allows e.g library makers to create strong small core and users/community to create their wrappers/integrations easily
- javcasas 4y agoExtension methods are "I want a function whose first parameter is this type defined outside, but the programming language shoehornes me so much into classes and objects that I have to do all this extra ~bullshit~ boilerplate to have a function whose first parameter is this type defined outside". Imagine having to create a monad, including the `pure` and `bind` operations every time you want to increment a variable. That would be bullshit, well, because it's bullshit. Even the haskell guys figured out it's bullshit and implemented types and operations (IORef) to simplify it. C# hasn't figured out yet you should not have to wrap your function in a namespace and a class.
- hardware2win 4y agoWeird definition since it misses the point. Extension methods are: I want to add a new method(not function) to object which I dont have control of (in the code sense) So I can call "externalObj.MyNewMethod()", so extend its behaviour
- javcasas 4y agoYep, a weird definition. "I want to add a new not-a-method (because it can't access private stuff, unlike real methods) so that I can do "externalObj.MyNewMethod()" because doing "myNewOperation(externalObj)" is somehow forbidden."
- hardware2win 4y agoOf course it cannot access internals because youd break "sane oop"