diff options
-rw-r--r-- | struct.c | 5 | ||||
-rw-r--r-- | txr.1 | 6 |
2 files changed, 9 insertions, 2 deletions
@@ -436,7 +436,6 @@ static void lazy_struct_init(val sinst, struct struct_inst *si) val cell = funcall(si->slot[0]); cons_bind (plist, args, cell); - si->lazy = 0; si->slot[0] = nil; if (args && !st->boactor) { @@ -471,8 +470,10 @@ static void lazy_struct_init(val sinst, struct struct_inst *si) INLINE void check_init_lazy_struct(val sinst, struct struct_inst *si) { - if (si->lazy) + if (si->lazy) { + si->lazy = 0; lazy_struct_init(sinst, si); + } } val make_lazy_struct(val type, val argfun) @@ -20186,6 +20186,12 @@ arranged by by a non-local exit such as an exception throw, the object's finalizers, if any, are invoked. +Lazy initialization does not detect cycles. Immediately prior to the lazy +initialization of a struct, the struct is marked as no longer requiring +initialization. Thus, during initialization, its instance slots may be +freely accessed. Slots not yet initialized evaluate as +.codn nil . + .coNP Macro @ with-slots .synb .mets (with-slots >> ({ slot | >> ( sym << slot )}*) < struct-expr |