Open
Description
function o(x,y,z){ return {x,y,z} }
Produces bytecode that sets the fields 1-by-1:
;; function o(x, y, z) { return {x, y, z} }
object
get_arg0 0 ; x
define_field x
get_arg1 1 ; y
define_field y
get_arg2 2 ; z
define_field z
return
It should be more efficient to use an "object template" that describes what properties the object has:
;; function o(x, y, z) { return {x, y, z} }
get_arg0 0 ; x
get_arg1 1 ; y
get_arg2 2 ; z
define_object <id> ; ( x y z -- o )
return
Benefits:
- reduces bytecode size
- object layout is known upfront, don't have to update JSShape repeatedly