Hologram v0.8.0: Elixir Gets JavaScript Interop

Unfortunately there are two problems with dropping the brackets:

  1. List ambiguity - JS.call(:obj, :processList, [1, 2, 3]) becomes impossible to distinguish between one argument (the array [1, 2, 3]) and three separate arguments.

  2. Arity clash - JS.call/2 calls a standalone function, JS.call/3 calls a method on a receiver. If args were optional, JS.call(:Decimal, :toNumber) could be either call/2 with one arg or call/3 with no args.

The explicit args list is also consistent with Kernel.apply/3, which always requires the args list. I actually considered naming it JS.apply at one point, so the parallel is intentional.

2 Likes