From 057bcab015647e6c880ec3fe218897527c6bb68c Mon Sep 17 00:00:00 2001 From: AlexKnauth Date: Fri, 15 Feb 2019 22:14:59 -0500 Subject: [PATCH] rename metafunction -> template-metafunction --- .../private/prop-template-metafunction.rkt | 47 ++++++++++--------- racket/collects/racket/private/template.rkt | 13 ++--- .../syntax/parse/experimental/template.rkt | 5 +- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/racket/collects/racket/private/prop-template-metafunction.rkt b/racket/collects/racket/private/prop-template-metafunction.rkt index f66167247c..c163b0124a 100644 --- a/racket/collects/racket/private/prop-template-metafunction.rkt +++ b/racket/collects/racket/private/prop-template-metafunction.rkt @@ -1,17 +1,17 @@ (module prop-template-metafunction '#%kernel - (#%provide (protect metafunction - prop:metafunction - (rename prop:metafunction? metafunction?) - metafunction-accessor)) + (#%provide (protect template-metafunction + prop:template-metafunction + (rename prop:template-metafunction? template-metafunction?) + template-metafunction-accessor)) - ;; The prop:metafunction structure type property can contain an + ;; The prop:template-metafunction structure type property can contain an ;; identifier bound to the run-time metafunction procedure, or the index of a ;; field containing such an identifier. ;; At run-time, when processing the template, the syntax object whose first ;; element is a metafunction identifiers is passed to this metafunction ;; procedure. - (define-values (prop:metafunction-guard) + (define-values (prop:template-metafunction-guard) (lambda (val struct-type-info-list) (if (exact-nonnegative-integer? val) ;; Field index, the field must contain an identifier bound to the run-time @@ -27,7 +27,7 @@ #f) metafunction-internal-id (raise-argument-error - 'prop:metafunction-guard + 'prop:template-metafunction-guard (format (string-append "the value of the ~a-th field should be" " an identifier") val) @@ -38,32 +38,37 @@ (λ (_instance) val) ;; Otherwise, raise an error. (raise-argument-error - 'prop:metafunction-guard + 'prop:template-metafunction-guard (string-append "an identifier, or an exact non-negative integer designating" " a field index within the structure that should contain an" " identifier.") val))))) - (define-values (prop:metafunction - prop:metafunction? - metafunction-raw-accessor) - (make-struct-type-property 'metafunction - prop:metafunction-guard)) + (define-values (prop:template-metafunction + prop:template-metafunction? + template-metafunction-raw-accessor) + (make-struct-type-property 'template-metafunction + prop:template-metafunction-guard)) - (define-values (metafunction-accessor) + (define-values (template-metafunction-accessor) (lambda (instance . more-args) (let-values ([(raw) (if (null? more-args) ;; no failure-result given - (metafunction-raw-accessor instance) + (template-metafunction-raw-accessor instance) (if (null? (cdr more-args)) (let-values ([(failure-result) (car more-args)]) - (metafunction-raw-accessor instance failure-result)) + (template-metafunction-raw-accessor instance + failure-result)) (error "invalid number of arguments [TODO]")))]) (raw instance)))) - ;; A default struct type with prop:metafunction. + ;; A default struct type with prop:template-metafunction. ;; (struct template-metafunction (proc-id) ;; #:property prop:template-metafunction (struct-field-index proc-id)) - (define-values (struct:metafunction metafunction metafunction? metafunction-ref _mf-set!) - (make-struct-type 'syntax-metafunction #f 1 0 #f - (list (cons prop:metafunction 0)) - (current-inspector)))) \ No newline at end of file + (define-values (_struct:template-metafunction + template-metafunction + _template-metafunction? + _template-metafunction-ref + _mf-set!) + (make-struct-type 'template-metafunction #f 1 0 #f + (list (cons prop:template-metafunction 0)) + (current-inspector)))) diff --git a/racket/collects/racket/private/template.rkt b/racket/collects/racket/private/template.rkt index cd2d5abb3e..85246b6223 100644 --- a/racket/collects/racket/private/template.rkt +++ b/racket/collects/racket/private/template.rkt @@ -13,9 +13,9 @@ datum ~? ~@ ~@! signal-absent-pvar - (for-syntax prop:metafunction - metafunction - metafunction?) + (for-syntax prop:template-metafunction + template-metafunction + template-metafunction?) (protect (for-syntax attribute-mapping attribute-mapping? @@ -30,7 +30,8 @@ ;; A Template (T) is one of: ;; - pattern-variable ;; - constant (including () and non-pvar identifiers) -;; - (metafunction . T) +;; - (template-metafunction . T) +;; ; or any other structure that implements prop:template-metafunction ;; - (H . T) ;; - (H ... . T), (H ... ... . T), etc ;; - (... T) -- escapes inner ..., ~?, ~@ @@ -273,7 +274,7 @@ (unless stx? (wrong-syntax (stx-car t) "metafunctions are not supported")) (disappeared! (stx-car t)) (define guide (parse-t (stx-cdr t) depth esc?)) - `(t-metafun ,(metafunction-accessor mf) ,guide + `(t-metafun ,(template-metafunction-accessor mf) ,guide (quote-syntax ,(let ([tstx (and (syntax? t) t)]) (datum->syntax tstx (cons (stx-car t) #f) tstx tstx)))))] @@ -495,7 +496,7 @@ ;; lookup-metafun : Identifier -> Metafunction/#f (define (lookup-metafun id) (define v (syntax-local-value id (lambda () #f))) - (and (metafunction? v) v)) + (and (template-metafunction? v) v)) (define (dotted-prefixes id) (let* ([id-string (symbol->string (syntax-e id))] diff --git a/racket/collects/syntax/parse/experimental/template.rkt b/racket/collects/syntax/parse/experimental/template.rkt index b52fd80e6e..056539a98e 100644 --- a/racket/collects/syntax/parse/experimental/template.rkt +++ b/racket/collects/syntax/parse/experimental/template.rkt @@ -1,7 +1,7 @@ #lang racket/base (require (for-syntax racket/base) (only-in racket/private/template - metafunction)) + template-metafunction)) (provide (rename-out [syntax template] [syntax/loc template/loc] [quasisyntax quasitemplate] @@ -21,7 +21,8 @@ (identifier? #'id) (with-syntax ([(internal-id) (generate-temporaries #'(id))]) #'(begin (define internal-id (make-hygienic-metafunction expr)) - (define-syntax id (metafunction (quote-syntax internal-id)))))])) + (define-syntax id + (template-metafunction (quote-syntax internal-id)))))])) (define current-template-metafunction-introducer (make-parameter (lambda (stx) (if (syntax-transforming?) (syntax-local-introduce stx) stx))))