diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-09-07 20:32:11 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-09-07 20:32:11 -0700 |
commit | e3aa3aac033df459debee3746feb437a506bc0f3 (patch) | |
tree | 5b34dd154dd4457e50a127acac854abccf4791a9 | |
parent | b8ee64789e18cbfe5e1dc7e64e0c9160e9c265b7 (diff) | |
download | txr-e3aa3aac033df459debee3746feb437a506bc0f3.tar.gz txr-e3aa3aac033df459debee3746feb437a506bc0f3.tar.bz2 txr-e3aa3aac033df459debee3746feb437a506bc0f3.zip |
Fix poorly chosen :postinit order.
* struct.c (call_postinitfun_chain): call base
handlers before derived ones, except in backward
compatibility mode.
* txr.1: Updated documentation of :postinit,
and added compatibility note.
-rw-r--r-- | struct.c | 6 | ||||
-rw-r--r-- | txr.1 | 37 |
2 files changed, 29 insertions, 14 deletions
@@ -366,10 +366,14 @@ static void call_initfun_chain(struct struct_type *st, val strct) static void call_postinitfun_chain(struct struct_type *st, val strct) { if (st) { - if (st->postinitfun) + int derived_first = (opt_compat && opt_compat <= 148); + + if (derived_first && st->postinitfun) funcall1(st->postinitfun, strct); if (st->super) call_postinitfun_chain(st->super_handle, strct); + if (!derived_first && st->postinitfun) + funcall1(st->postinitfun, strct); } } @@ -19897,29 +19897,30 @@ The .code :postinit specifier is very similar to .codn :init . -There are two differences. The first difference -is that +Both specify forms which are evaluated during object instantiation. +The difference is that the .codn body-form -s +of a +.code :postinit are evaluated after other initializations have taken -place. The argument material from the +place, including the +.code :init +initializations, as a second pass. By the time +.code :postinit +initialization runs, the argument material from the .codn make-struct , .code new or .code lnew invocation has already been processed and stored into slots. -The second difference is that -.code :postinit -actions registered at different levels of the type's -inheritance hierarchy are invoked in the opposite -order compared to +Like .code :init -action. The +actions, .code :postinit -specific to a derived struct type is called before -the -.code :postinit -of its base type. +actions registered at different levels of the type's +inheritance hierarchy are invoked in the base-to-derived +order. .meIP (:fini <> ( param ) << body-form *) The .code :fini @@ -43747,6 +43748,16 @@ of these version values, the described behaviors are provided if is given an argument which is equal or lower. For instance .code "-C 103" selects the behaviors described below for version 105, but not those for 102. +.IP 148 +Up until version 148, the +.code :postinit +handlers specified in a +.code defstruct +were executed in derived-to-base order, opposite to the +order of execution of +.code :init +handlers. Specifying 148 or earlier compatibility provides this +old behavior. .IP 145 In versions 144 and 145, \*(TX opened files in text mode on Cygwin, enabling conversion between CR-LF line endings and abstract newline |