Getting the desugared part of a Scala for/comprehension expression?

As I already said in the other topic, scalac -print prints out scala code, not java. It translates all scala keywords that are not directly compatible with java to normal scala code. It is not possible to let the compiler translate only parts afaik. But basically a for-comprehension is always translated the same way. A … Read more

In detail, how does the ‘for each’ loop work in Java?

for (Iterator<String> i = someIterable.iterator(); i.hasNext();) { String item = i.next(); System.out.println(item); } Note that if you need to use i.remove(); in your loop, or access the actual iterator in some way, you cannot use the for ( : ) idiom, since the actual iterator is merely inferred. As was noted by Denis Bueno, this … Read more

WITH statement in Java

No. The best you can do, when the expression is overly long, is to assign it to a local variable with a short name, and use {…} to create a scope: { TypeOfFoo it = foo; // foo could be any lengthy expression it.bar(); it.reset(true); myvar = it.getName(); }

Is there a way to implement custom language features in C#?

Microsoft proposes Rolsyn API as an implementation of C# compiler with public API. It contains individual APIs for each of compiler pipeline stages: syntax analysis, symbol creation, binding, MSIL emission. You can provide your own implementation of syntax parser or extend existing one in order to get C# compiler w/ any features you would like. … Read more