Pass the constant arguments of Dict and Object functions without @as(json)
Why
A prototype for deprecating @as(json) on external arguments. The seven stdlib uses become an external that takes the constant plus an @inline function of the same name that passes {} or null, the way Array.reduce reorders its arguments. Calls compile to the same JavaScript as before.
JS unchanged (call sites):
let merged = target->Dict.concat(dict{"b": 3})let bare = Object.createWithNull()
js
let merged = Object.assign({}, target, { b: 3}); let bare = Object.create(null);
Review
- What changes for users?
Stdlib_Dict.jsandStdlib_Object.jsnow export these functions, asStdlib_Array.jsexportsreduce. A function value such asDict.copypassed around calls the exported function instead of a wrapper made at the use site.