Ticket #1770: 0001-Add-expand1-procedure-in-module-chicken-syntax.patch

File 0001-Add-expand1-procedure-in-module-chicken-syntax.patch, 2.2 KB (added by John Croisant, 3 years ago)
  • chicken.syntax.import.scm

    From 65fc5cedc586c571b41decb5fb6013089f6031c5 Mon Sep 17 00:00:00 2001
    From: John Croisant <john@croisant.net>
    Date: Sun, 11 Jul 2021 23:15:01 -0500
    Subject: [PATCH 1/2] Add `expand1` procedure in module (chicken syntax).
    
    Like `expand` but expands the form only once, instead of repeating
    until a non-macro form is produced. This is helpful when debugging
    macros because you can see the intermediate results of the expansion.
    ---
     chicken.syntax.import.scm      | 1 +
     expand.scm                     | 4 ++++
     manual/Module (chicken syntax) | 8 ++++++++
     3 files changed, 13 insertions(+)
    
    diff --git a/chicken.syntax.import.scm b/chicken.syntax.import.scm
    index 13983816..da39de12 100644
    a b  
    3131 'chicken.syntax
    3232 'expand
    3333 '((expand . chicken.syntax#expand)
     34   (expand1 . chicken.syntax#expand1)
    3435   (get-line-number . chicken.syntax#get-line-number)
    3536   (strip-syntax . chicken.syntax#strip-syntax)
    3637   (syntax-error . chicken.syntax#syntax-error)
  • expand.scm

    diff --git a/expand.scm b/expand.scm
    index e815a2b9..e6dd57c4 100644
    a b  
    3636
    3737(module chicken.syntax
    3838  (expand
     39   expand1
    3940   get-line-number
    4041   strip-syntax
    4142   syntax-error
     
    305306          (loop exp2)
    306307          exp2) ) ) )
    307308
     309(define (expand1 exp #!optional (se (##sys#current-environment)) cs?)
     310  (nth-value 0 (##sys#expand-0 exp se cs?)) )
     311
    308312
    309313;;; Extended (DSSSL-style) lambda lists
    310314;
  • manual/Module

    diff --git a/manual/Module (chicken syntax) b/manual/Module (chicken syntax)
    index eaa7dbd1..ab169c9b 100644
    a b comparison {{(compare sym 'abc)}} should be written as {{(compare sym 
    301301If {{X}} is a macro-form, expand the macro (and repeat expansion
    302302until expression is a non-macro form).  Returns the resulting expression.
    303303
     304==== expand1
     305
     306<procedure>(expand1 X)</procedure>
     307
     308If {{X}} is a macro-form, expand the macro only once.  Unlike
     309{{expand}}, does not repeat expansion when the resulting expression is
     310itself a macro-form.  Returns the resulting expression.
     311
    304312=== Macro helper procedures
    305313
    306314==== begin-for-syntax