mitranim/jisp

Operator-functions need to fully mimic real functions

Opened this issue · 0 comments

Operator-functions are things like + or <:

(+ 2 3)

We need to be able to use them in all the same ways as normal functions, including this following.

Pass by name:

(array.filter <)

Property notation:

(+.apply `(1 2 3))

Spread:

(* ...`(3 4) `(5 6))

Supporting this requires the following components:

  • Impostor functions (trivial, partly implemented, see operators.jisp) to be embedded with .toString
  • Hoisting and embedding mechanism: already implemented, will need a few tweaks for this
  • Detect when the operator is referenced a non-standard way (one of the ways listed above), trigger replacement and embedding
  • Replacement: replace the operator glyph with the name of the impostor function
  • Treat impostor function names as service variables and guarantee that they don’t clash with user-defined names in any scope