Re:How an Optimizing Compiler Works
by _bxg1 on Tuesday November 12, 2019 @12:08AM
(#21511679)
Slightly off-topic, but does Java have standalone (without a class) functions now? He said he was using Java but I didn't recognize some of this syntax. I know it's been changing a lot the past few years (and it's been a few years since I've used it).
[ Parent
| on HN ]
Re:How an Optimizing Compiler Works
by dodobirdlord on Tuesday November 12, 2019 @03:20AM
(#21512463)
Sort of yes but not really. Java has a concept now of a Functional Interface, an interface that has only one abstract method. Classes that implement a functional interface can be treated in a lot of ways like functions, and there is syntactic sugar that amounts to inferring that an object can be treated as a function by calling its only method if it is known in the scope as an interface type with only one method. There's also syntactic sugar for a concept called "lambdas", by which one can inline declare anonymous classes with only one method by just defining the method.
Nope. I think he simply used that notation to keep things simple/concise and focus on the important pieces.