diff --git a/sex-modules.scm b/sex-modules.scm index 9939bd8..744e68a 100644 --- a/sex-modules.scm +++ b/sex-modules.scm @@ -65,12 +65,16 @@ module-path)))) (define (read-public-interface module-path) - ;; pub fns are reduced to prototypes, other pub forms are just pasted + ;; pub fns are reduced to prototypes, other pub forms are just pasted. + ;; Declaration order is kept: a module that declares a type and then a + ;; pub fn taking it has to paste them that way round, or the prototype + ;; names a type C has not seen. (let ((raw-forms (read-from-file module-path))) - (fold - process-public-interface-form - (list) - raw-forms))) + (reverse + (fold + process-public-interface-form + (list) + raw-forms)))) (define (public-fn-interface raw-form) ;; (pub fn name args ret . body) -> prototype, keeping a docstring so