JSCall

From Esolang
Jump to navigation Jump to search

JSCall is an esoteric subset of the JavaScript language inspired by JSFuck. JSCall is invented by User:Hakerh400 in 2021.

Overview

Every JSCall program consists of two parts. The first part is the base combinator: a function that takes a single argument and performs some computation. Here is the base combinator:

const aa = a => a
  (a => a => a => a => a => a)
  (a => a
    (a => a
      (a => a
        (a => a
          (a => b => a + b)
          (a => +a))
        (a => a
          (a => !a)
          (a => b => b [a])))
      (a => a
        (a => b => c => c [a] (b))
        (a => [a])))
    (a => a
      (a => b => c => a (c) (b (c)))
      (a => b => a)))

Every program must have the base combinator at the beginning. The second part of the program must have the following syntax:

const ident1 = ident2(ident3)
    , ident4 = ident5(ident6)
    , ident7 = ident8(ident9)
    ...

Each of those idents must be defined before it is used. In the example above, ident2 and ident3 can only be aa (the base combinator), because at the time of defining ident1, only the base combinator is defined. In the definition of ident2, we can use aa and/or ident1, and so on.

There are also more contraints: each identifier, except the last one, must be used in the definition of some other identifier. No global identifiers can be used, except if they are defined in the program itself. The program must be run in strict mode (must have 'use strict' at the beginning of the program). The program must be enclosed in an IIFE (immediately invoked function expression). No identifier can reference itself. Multiple identifier definitions can be written in the same line.

No two identifiers can have the same definition. That is, we cannot have a = x(y) and b = x(y). The right hand side must be syntactically different for each identifier definition.

Additionally, if there are two consecutive definitions a = b(c), d = e(f) such that neither e or f are a, then the first definition that references a (let it be in the definition of some identifier x) must have a called with the identifier that immediately precedes x. For example:

...
, a = b(c)
, d = e(f)
...
, g = m(n)
, x = a(g)
...

In the example above, different names represent different identifiers. The first definition that references a is x and it is defined as a(g), where g is the identifier that immediately precedes x. We could not have x = g(a) or x = a(m), etc. So, if x is the first identifier that refereces a, it has only one possible definition. That would not apply if d referenced a. For example, d could be defined as e(a) and then no restriction regarding a would be applied to x.

Computational class

It is Turing complete. Any JavaScript program can be translated into JSCall program.

Example

The following program displays an alert with Hello, World! message.
If run in Node.js, it prints the message to the console instead.

(() => {
  'use strict'

  const aa = a => a
    (a => a => a => a => a => a)
    (a => a
      (a => a
        (a => a
          (a => a
            (a => b => a + b)
            (a => +a))
          (a => a
            (a => !a)
            (a => b => b [a])))
        (a => a
          (a => b => c => c [a] (b))
          (a => [a])))
      (a => a
        (a => b => c => a (c) (b (c)))
        (a => b => a)))

  const ab = aa(aa), ac = aa(ab), ad = ac(ab), ae = ad(ad), af = ad(ae)
      , ag = ad(af), ah = ad(ag), ai = ag(ah), aj = ah(ai), ak = aj(ag)
      , al = ak(ak), am = al(ah), an = ah(am), ao = ag(ag), ap = an(ao)
      , aq = ap(ae), ar = aq(ab), as = aq(ag), at = ac(ag), au = as(at)
      , av = ar(au), aw = ar(av), ax = as(au), ay = as(ax), az = al(aw)
      , ba = ap(az), bb = ap(ay), bc = bb(ae), bd = ba(bc), be = as(av)
      , bf = be(ay), bg = be(bf), bh = ay(bg), bi = bh(bf), bj = ay(bi)
      , bk = bj(bi), bl = bj(bk), bm = bd(bl), bn = ay(bf), bo = bn(bf)
      , bp = bd(bo), bq = bp(bf), br = ay(bq), bs = bd(bk), bt = bs(bf)
      , bu = ay(bt), bv = bd(bi), bw = bv(bf), bx = ay(bw), by = bp(bg)
      , bz = bx(by), ca = bu(bz), cb = br(ca), cc = aw(cb), cd = ar(at)
      , ce = ar(cd), cf = aw(bo), cg = cf(bo), ch = ce(cg), ci = cc(ch)
      , cj = bm(ci), ck = ay(cj), cl = bj(bl), cm = bj(cl), cn = bj(cm)
      , co = bd(cn), cp = co(ci), cq = ay(cp), cr = bv(cg), cs = ay(cr)
      , ct = bm(bf), cu = ay(ct), cv = ay(by), cw = bv(bg), cx = ay(cw)
      , cy = bs(bg), cz = ay(cy), da = cq(cw), db = cv(da), dc = ck(db)
      , dd = cz(dc), de = cx(dd), df = cv(de), dg = cu(df), dh = cs(dg)
      , di = cq(dh), dj = ck(di), dk = aw(dj), dl = dk(ae), dm = ap(dl)
      , dn = dm(ae), dp = ak(dn), dq = bd(cl), dr = dq(bf), ds = ay(dr)
      , dt = cx(cr), du = cz(dt), dv = cv(du), dw = ds(dv), dx = cx(dw)
      , dy = ay(dx), dz = ah(ay), ea = dz(ae), eb = ea(cl), ec = bj(eb)
      , ed = bj(ec), ee = bj(ed), ef = bd(ee), eg = dk(bo), eh = ef(eg)
      , ei = cq(eh), ej = cx(ei), ek = br(ej), el = ay(ek), em = aw(bk)
      , en = bd(eb), eo = dk(ch), ep = en(eo), eq = dy(ep), er = ay(eq)
      , es = dp(er), et = aw(bi), eu = as(cd), ev = cv(cp), ew = ay(ev)
      , ex = ay(eh), ey = ex(dr), ez = bx(ey), fa = cs(ez), fb = aw(fa)
      , fc = dk(bw), fd = fb(fc), fe = ew(fd), ff = eu(fe), fg = bj(cn)
      , fh = ay(fg), fi = fh(eb), fj = ay(fi), fk = ea(eb), fl = fj(fk)
      , fm = ff(fl), fn = ay(fk), fo = fn(bk), fp = bj(fo), fq = ay(fp)
      , fr = ea(fk), fs = ea(fr), ft = ay(fs), fu = ea(fs), fv = ft(fu)
      , fw = fq(fv), fx = fm(fw), fy = et(fx), fz = ay(fy), ga = fz(dr)
      , gb = bx(ga), gc = ck(gb), gd = cu(gc), ge = ds(gd), gf = es(ge)
      , gg = ap(eu), gh = gg(cg), gi = bd(cm), gj = gi(cg), gk = ay(gj)
      , gl = ck(ct), gm = gk(gl), gn = bu(gm), go = bx(gn), gp = cv(go)
      , gq = gk(gp), gr = gh(gq), gs = gh(fe), gt = gs(ch), gu = gr(gt)
      , gv = gf(gu), gw = em(gv), gx = ay(gw), gy = ay(bl), gz = gy(fo)
      , ha = ff(gz), hb = ay(cm), hc = ay(fr), hd = hc(fs), he = hb(hd)
      , hf = ha(he), hg = et(hf), hh = ay(hg), hi = bx(cw), hj = hh(hi)
      , hk = gx(hj), hl = ay(hk), hm = bs(cg), hn = ay(hm), ho = hn(dr)
      , hp = cq(ho), hq = gx(hp), hr = hl(hq), hs = el(hr), ht = aw(hs)
      , hu = ht(fc), hv = ay(eb), hw = hv(fr), hx = hu(hw), hy = dy(hx)
      , hz = ay(hy), ia = ak(hz), ib = bj(hw), ic = hu(ib), id = bb(ic)
      , ie = ia(id), ig = dp(ie), ih = ak(ig), ii = hv(gz), ij = ay(ii)
      , ik = ij(fr), il = hu(ik), im = ay(il), io = bj(ik), ip = hu(io)
      , iq = im(ip), ir = bb(iq), is = ir(bw), it = ay(is), iu = ay(bk)
      , iv = iu(hd), iw = hu(iv), ix = ir(iw), iy = it(ix), iz = ay(iy)
      , ja = ak(iz), jb = ak(bx), jc = bb(iw), jd = jb(jc), je = ja(jd)
      , jf = ih(je), jg = hb(hw), jh = hu(jg), ji = jf(jh), jj = ji(fu)
      , jk = jj(cl), jl = hu(jk), jm = ea(jl), jn = jf(jm), jo = ap(aw)
      , jp = gk(ct), jq = hh(jp), jr = cv(jq), js = es(jr), jt = jo(js)
      , ju = cx(by), jv = ds(ju), jw = bu(jv), jx = bx(jw), jy = jt(jx)
      , jz = jn(jy), ka = fh(hd), kb = hu(ka), kc = cq(kb), kd = bu(kc)
      , ke = aw(kd), kf = bu(dr), kg = cq(kf), kh = cu(kg), ki = cs(kh)
      , kj = cq(ki), kk = ck(kj), kl = jt(kk), km = ke(kl), kn = jz(km)
      , ko = ji(ka), kp = ko(bl), kq = ji(kp), kr = kq(fi), ks = hu(kr)
      , kt = ay(ks), ku = ds(cw), kv = fz(ku), kw = fz(kv), kx = kt(kw)
      , ky = ay(kx), kz = cu(dr), la = bx(kz), lb = gx(la), lc = ky(lb)
      , ld = ew(lc), le = gh(ld), lf = le(hg), lg = ay(lf), lh = bu(cp)
      , li = bu(lh), lj = ds(li), lk = lg(lj), ll = ay(lk), lm = ay(ee)
      , ln = bj(fr), lo = lm(ln), lp = hu(lo), lq = ay(lp), lr = lq(ep)
      , ls = ay(lr), lt = fq(kp), lu = hu(lt), lv = le(lu), lw = ay(lv)
      , lx = bu(hm), ly = cx(lx), lz = cq(ly), ma = lw(lz), mb = ay(ma)
      , mc = hu(ln), md = mb(mc), me = ls(md), mf = ll(me), mg = kn(mf)
})()