Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on What's new in Java 12, 13 and 14. Parent comment
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);
I 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.
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:
> 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.