~subsetpark/fugue

c5611d7e56a8bbfff75540dfbb6f97348477cc16 — Zach Smith 3 years ago 64a9e7a
Rely on self in init - dont hardcode reference to proto
1 files changed, 3 insertions(+), 3 deletions(-)

M fugue.janet
M fugue.janet => fugue.janet +3 -3
@@ 110,17 110,17 @@
            (let [inst @{:_meta @{:object-type :instance
                                  :object-id (,make-object-id)}}]
              # Recursively lookup defaults in prototype hierarchy
              (var source-of-defaults ,name)
              (var source-of-defaults self)
              (while source-of-defaults
                (let [proto-id (get-in source-of-defaults [:_meta :object-id])
                      defaults (,get-proto-defaults proto-id)]
                  (loop [[name default-value] :pairs defaults]
                  (loop [[default-key default-value] :pairs defaults]
                    # Ensure the value inserted into a new instance is
                    # distinct from any previous examples.
                    # Theoretically we might want to directly insert
                    # the value, but until the usecase arises we can
                    # always make a copy.
                    (put inst name (,make-copy default-value))))
                    (put inst default-key (,make-copy default-value))))
                # Recurse to grandparent
                (set source-of-defaults (table/getproto source-of-defaults)))