From a4880f1b9694c05b58eff84abf99381e3fdd97be Mon Sep 17 00:00:00 2001 From: alex-eg Date: Mon, 19 Oct 2026 18:21:10 +0300 Subject: [PATCH] process an ops method's prototype once Registering a method processed its prototype only for the signature it records, and a method called from above was processed again to be declared ahead. --- semen.scm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/semen.scm b/semen.scm index 7d3cfc85..915b2a35 100644 --- a/semen.scm +++ b/semen.scm @@ -425,12 +425,16 @@ (sex-error form "ops needs a type name" form)) (let* ((methods (map (lambda (m) (register-op type m)) (cddr form))) (fns (remove comment-form? methods)) + ;; the signatures too, which a call's receiver is fitted to + (protos (map (lambda (m) (process-fn (sex-fn-prototype m) (list))) fns)) (bodies (map (lambda (m) (if (comment-form? m) (list m) (process-fn m (list)))) methods)) - (early (filter (lambda (m) (called-before? m methods bodies)) fns))) - (append (append-map identity (reverse bodies)) - (fold (lambda (m acc) (process-fn (sex-fn-prototype m) acc)) acc early))))) + (early (filter-map (lambda (m proto) + (and (called-before? m methods bodies) proto)) + fns protos))) + (append (concatenate (reverse bodies)) + (fold append acc early))))) ;;; The method's fn form, renamed to vec2/length, once it is registered ;;; under `length'; a comment is passed along @@ -447,8 +451,6 @@ (let* ((qualified (qualify-op type name)) (renamed (rename-fn form qualified))) (add-method! type name qualified) - ;; its signature too, which a call's receiver is fitted to - (process-fn (sex-fn-prototype renamed) (list)) renamed))))) ;;; Does a body written above METHOD call it?