3 ms·
What's with the "#" sign? Is that new for lambdas, or an existing Java symbol?
by euroclydon 16y ago
What's with the "#" sign? Is that new for lambdas, or an existing Java symbol?
- ebiester 16y agoThat's new for lambdas.
- tlack 16y agoJava isn't very "symboly" in practice. Any idea why they made such an unusual choice? I'm not against it (I prefer symbols to long words generally, even if they have a slightly longer learning curve), but it seems unlike the rest of the Java spec.
- RodgerTheGreat 16y agoWell, the alternative is adding a new keyword, and it's difficult to do that without risking breaking any existing code that uses whatever identifier they choose. Breaking old code is even less "Java" than introducing new symbols. edit: Actually, now that I think about it, this wouldn't be the first time they introduced a new keyword with a language update. So much for that argument: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_k...
- deleted 16y ago[deleted]
- bokchoi 16y agoIt's borrowed from the javadoc syntax, unfortunately.
- svv 16y agoThis syntax is similiar to Stephen Colebourne's FCM proposal: http://docs.google.com/Doc?id=ddhp95vd_6hg3qhc http://docs.google.com/Doc?id=ddhp95vd_6hg3qhc That proposal also used the "#" symbol, with the following rationale: "The symbol is already used within Javadoc to separate the class name from the method name in exactly this manner. The method literal syntax merely brings the Javadoc convention into Java source code." It's a reasonable choice for full first-class methods; it doesn't fit quite as nicely if Oracle only introduces closures as a syntax sugar for anonymous classes. But I think it's OK anyway -- it's concise and even looks a bit like clojure :-)