From a63492e9c067d70eccc2c4bd0972be8fad4ff0d4 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 29 Mar 2016 13:03:38 -0700 Subject: [PATCH] interpolate: make interpolate and interpolate-locals symmetric. --- basis/functors/functors.factor | 2 +- basis/interpolate/interpolate.factor | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/basis/functors/functors.factor b/basis/functors/functors.factor index 95b0f9057a..eefa7a31da 100644 --- a/basis/functors/functors.factor +++ b/basis/functors/functors.factor @@ -123,7 +123,7 @@ FUNCTOR-SYNTAX: inline [ last-word make-inline ] append! ; FUNCTOR-SYNTAX: call-next-method T{ fake-call-next-method } suffix! ; : (INTERPOLATE) ( accum quot -- accum ) - [ scan-token interpolate-locals ] dip + [ scan-token interpolate-locals-quot ] dip '[ _ with-string-writer @ ] suffix! ; PRIVATE> diff --git a/basis/interpolate/interpolate.factor b/basis/interpolate/interpolate.factor index 59bcc06b17..fd00b1fdd1 100644 --- a/basis/interpolate/interpolate.factor +++ b/basis/interpolate/interpolate.factor @@ -45,7 +45,7 @@ TUPLE: anon-var ; dup stack-var? [ n>> [ or ] keep max ] [ drop ] if ] reduce ; -:: interpolate-quot ( str quot -- quot' ) +:: (interpolate-quot) ( str quot -- quot' ) str parse-interpolate :> args args max-stack-var :> vars @@ -67,15 +67,24 @@ TUPLE: anon-var ; PRIVATE> +: interpolate-quot ( str -- quot ) + [ [ get ] ] (interpolate-quot) ; + MACRO: interpolate ( str -- quot ) - [ [ get ] ] interpolate-quot ; + interpolate-quot ; : interpolate>string ( str -- newstr ) [ interpolate ] with-string-writer ; inline -: interpolate-locals ( str -- quot ) - [ dup search [ [ ] ] [ [ get ] ] ?if ] interpolate-quot ; +: interpolate-locals-quot ( str -- quot ) + [ dup search [ [ ] ] [ [ get ] ] ?if ] (interpolate-quot) ; + +MACRO: interpolate-locals ( str -- quot ) + interpolate-locals-quot ; + +: interpolate-locals>string ( str -- newstr ) + [ interpolate-locals ] with-string-writer ; inline SYNTAX: [I "I]" parse-multiline-string - interpolate-locals append! ; + interpolate-locals-quot append! ; -- 2.34.1