5 ms·
In java lamdas are just a syntactic sugar for anonymous inner classes, with the same resulting limitations, so one can either argue that java always had lamdas,
by dfox 2y ago
In java lamdas are just a syntactic sugar for anonymous inner classes, with the same resulting limitations, so one can either argue that java always had lamdas, but with weird verbose syntax, or that java does not really have lambdas (in which case C++ and Python also do not have lambdas, as the semantics are similar).
- cmrdporcupine 2y agoYeah, I moved on from Java before lambdas were standardized, so can't comment much but what was painful was watching just how bloody long it took to get them into the language.
- trealira 2y agoThe point of a language feature is to have support in the syntax and in the compiler for it. Going down that lane, you could say that C has always had object-oriented polymorphism, because you can manually insert pointers to tables of functions in your data structures, and call it just verbose syntax for the virtual methods featured in C++.
- lmm 2y agoOr syntax actually matters. Which ironically is where the lisp people went wrong.
- kazinator 2y agoSyntax does matter. That's one area where the Lisp people went right. Lisp syntax is nice to work with irrespective of everything else, which was quite a discovery, which came as a surprise. The Lisp project itself didn't expect it; Lisp was supposed to be programmed in M-expressions. Furthermore, there was a second generation project, Lisp 2, that provided an Algol-like syntax over top of the Lisp internals. Because syntax matters, M-expressions and Algol syntax for Lisp fell by the wayside. Other subsequent attempts also faced very limited success.
- aredox 2y agoWhat would those M-expressions have looked like?
- Y_Y 2y agoMathematica. Mathematica is the M-expression language. It's actually very expressive and has nice tricks like multimedia literals and the ability to do some fancy almost-tex rendering in expression, but deep down it's all sexps and lists and symbolic manipulation thereof (and an FFI). (I think they tried to rebrand the language a couple of years back as "Wolfram", lol.)
- lispm 2y agoTechnically what Mathematica calls "lists" are one-dimensional arrays (aka vectors in Lisp), but not Lisp-like singly-linked lists. This is an example of an M-Expression in the original definition of Lisp: [eq[third[(A B C (D . E))];C]→cons[D;cdr[((A 1 2 3) B C)]; T→car[x]] which is roughly equivalent to the Lisp S-Expression (COND ((EQ (THIRD (QUOTE (A B C (D . E)))) (QUOTE C)) (CONS (QUOTE D) (CDR (QUOTE ((A 1 2 3) B C))))) (T (CAR X))) Which evaluates to (D B C)
- Y_Y 2y agoIs the underlying implementation a necessary condition? Mathematica is a heap of shit, but it was deliberately based on lisp by sensible people and has astonishingly similar semantics. Afaik the language spec doesn't define anything incompatible with OG lisp and you can treat it like one without inconsistencies.
- lispm 2y agoIt was more influenced by computer algebra systems written in Lisp, like Macsyma (-> Maxima), REDUCE, and others. > astonishingly similar semantics The "Wolfram language" has at its core a rewrite rule systems. Expressions are being rewritten by applying transformations to it. Lisp does not use anything like that. Lisp has an evaluator mechanism, based on fixed evaluation rules (+ macro transformations, which are again Lisp functions). As a result, code in the Wolfram language is difficult to (fully) compile. Good and extensive Lisp compilers exist since the early 60s. Current examples of complete compilers are SBCL for Lisp and Chez Scheme for Scheme. The Wolfram language also has no formal spec (compare to something like Scheme) and the language itself is not open sourced, including its main implementation. It's basically defined by its main implementation, while its proprietary language documentation looks like written in a such way to prevent implementations of the language.
- pjmlp 2y agoThere are definitly not, they are implemented via invokedynamic. "Implementing Lambda Expressions in Java with Brian Goetz" https://www.youtube.com/watch?v=Uns1dm3Laq4 https://www.youtube.com/watch?v=Uns1dm3Laq4 C++ lambdas follow the functor class model, and they also capture the environment, the only difference is that we get to say what we want captured.