GSET
Targets

JavaScript Target

Node.js output — console.log, let, switch, and object literals.

Implemented

gset run foo.js defaults to the JavaScript target; --target javascript or --target js forces it. Generated files run with node.

Feature coverage

FeatureEmits
printconsole.log(...)
var/val/let/constlet declarations
true/false/nulltrue/false/null
arrays / maps[ ... ] / { ... }
if/elif/elseif (…) {} else if (…) {} else {}
match/caseswitch (…) { case …: … break; }
while, for…in, foreachwhile/for...of/indexed loop
functionsfunction name (...) {...}
lambdas(x) => x * 2
**Math.pow(base, exp)
try/catch/finallytry {} catch (e) {} finally {}
throwthrow …;
list comprehensionsitems.map(x => …)

Brace correctness

The JavaScript backend had a known defect where else if and catch/finally chains emitted one } too many. Both are fixed and regression-tested — every emitted { has exactly one matching }.

Verified example

$ gset run hello.js --target javascript
let name = "World";
let count = 3;
console.log("Hello, " + name);
while (count > 0) {
    console.log(count);
    count = count - 1;
}

Output:

Hello, World
3
2
1

Watch out

  • Strict equality: the emitter produces ==/!=, not ===/!==. Fine for string/number compares; use explicitly typed GSET when you need coercion-free checks.
  • Statements need ;: expression statements and assignments receive a trailing ;; some one-liners rely on ASI only where safe.
  • Print output differs from Python: console.log(1, "and", true) → 1 and true.
  • Classes: class Person {} shells + new → Person(...) are emitted; method bodies aren't. See Classes.

Runtime

Requires node on PATH. Override with compiler.javascript.command in gset.conf.

On this page