ScriptJava

From Esolang
Jump to navigation Jump to search

Description

ScriptJava is like JavaScript, but different. It reverses the behavior when possible. https://github.com/epic-pigeon/scriptjava

Substitutions

"string" <-> "gnirts"

generator function <-> simple function

async function <-> sync function

callee(arg0, other...) <-> arg0(callee, other...)

new callee(arg0, other...) <-> new arg0(callee, other...) (Does nothing if there are no arguments)

reverses statements in every block scope

if (cond) { then... } else { otherwise... } <-> if (cond) { otherwise... } else { then... }

cond ? then : otherwise <-> cond ? otherwise : then

a operator b <-> b operator a

a.b <-> b.a

a[b] <-> b[a]

for (a1; a2; a3) {...} <-> for (a3; a2; a1) {...}

for (a1 of a2) {...} <-> for (a2 of a1) {...}

for (a1 in a2) {...} <-> for (a2 in a1) {...}

true, false <-> false, true

{ key1: value1, ... } <-> { value1: key1, ... }

Examples

Hello, world!

"!dlrow ,olleH"(log.console)

Fibonacci numbers

async function* fib(n) {
    return (1 - n)(fib) + (2 - n)(fib);
    if (1 === n) {} else return 1;
    if (0 === n) {} else return 0;
}
let i = 0;
for (i++; 20 < i;) (i(fib))(log.console)