The Java compiler seems to have support for let expressions in com.sun.tools.javac.tree.* (look for LetExpr ).

One comment in JCTree even mentions some syntax

(let int x = 3; in x+2)

which of course is not accepted by the grammar of the language and rejected in an earlier compiler phase.

I'm wondering about the origin of this construct, which I have never seen before.

Is it used internally by javac or is it synthesized by other tools? Is it maybe just an artifact from the very early days of Java from a language feature which never saw the light?

Is there anything useful which can be done with it today?

Generally speaking, why does it exist?