Re:Update to the .NET Language Strategy
by hardware2win on Thursday February 09, 2023 @09:52AM
(#34724782)
Weird 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
Re:Update to the .NET Language Strategy
by javcasas on Thursday February 09, 2023 @12:08PM
(#34727218)
Yep, 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."
Re:Update to the .NET Language Strategy
by hardware2win on Thursday February 09, 2023 @12:18PM
(#34727418)
Of course it cannot access internals because youd break "sane oop"
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.