Earlier quoted context omitted.
I'm still not sure why imperative/OOP language have been so resistant to adding pattern-matching of the sort seen in Haskell and OCaml. There are plenty of almost entirely pointless features that get implemented in major languages, like 'events' in C#. They add almost no value to the programmer. Pattern-matching would be really useful for avoiding rats' nests of control-flow, but until recently no major imperative la…
I hugely disagree with you thinking that event is useless in C#, rather I think it should have had been implemented as built-ins in every major programming language in the style of what C# did. Not only that it makes every possible event explicit and stand-out on its own, which is good for inline optimization and documentation (think about the catastrophic event handling in JS world), it also provides a standard, muc…
I agree that's nice to have - essentially announcing events as special in the type system.
> good for inline optimization
Any optimisation here should be possible with an ordinary implementation of the observer pattern, no?
> it also provides a standard, much more intuitive syntax using formal function delegate declaration
I'm not convinced that it does. Without events, we can still write:
var h = () => { doStuff(); doOtherStuff(); };
subject.registerObserver(h);
> Before having lambdas in Java, we need to add an EventListener as a variable and adding an extra interfaceI suspect we're both right, then: events were introduced for a good reason, but now that C# has lambdas and such, they don't seem to add much.