but it breaks in Javascript because it assumes that the 2nd lambda is an argument to the first lambda. Which is why is gives a Javascript error which is something like /\(x) is not a function.
The fix to this is:
During codegen, we need to enclose { } around both the generated /\s.
But we can't have { } around generated /\s that are used within expressions, since that's a Javascript error. We can't do
let f = { (function (.... }
So, during codegen, we need to distinguish between 'lambdas as expressions' and 'lambdas in expressions'.
// lambdas as expressions
(/\(x) => print(x);)("lambda 1 - 1 arg");
// lambdas in expressions
val ten = (/\(x) => x + x;)(5);
and put braces only around the first case.
If we do this, we don't need to add ;s after prints, as mentioned in #75 , since it'll fix both problems.
This is correct JSJS code
but it breaks in Javascript because it assumes that the 2nd lambda is an argument to the first lambda. Which is why is gives a Javascript error which is something like
/\(x) is not a function
. The fix to this is: During codegen, we need to enclose { } around both the generated/\
s. But we can't have { } around generated/\
s that are used within expressions, since that's a Javascript error. We can't doSo, during codegen, we need to distinguish between 'lambdas as expressions' and 'lambdas in expressions'.
and put braces only around the first case. If we do this, we don't need to add ;s after prints, as mentioned in #75 , since it'll fix both problems.