i understand Jean, do you have an idea to fix this macro, i'm not far away from the result as the display show it
i'm modifying a macro that worked but i want to write it in a more modern way (macro talking), this do the same than in Python in this example: Python 3.11.2 (v3.11.2:878ead1ac1, Feb 7 2023, 10:02:41) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin Type "help", "copyright", "credits" or "license()" for more information. [0, 1 ,2 ,3, 4, 5,6 ,8,9][6 - 4 : 5 + 2] [2, 3, 4, 5, 6] the guile output: scheme@(guile-user)> {#(1 2 3 4 5 6 7 8 9)[6 - 4 : 5 + 2]} $bracket-apply$ : parsed-evaluated-args=((- 6 4) : (+ 5 2)) While compiling expression: Syntax error: unknown file:#f:#f: encountered raw symbol in macro output in subform - of ($bracket-apply$ #(1 2 3 4 5 6 7 8 9) 6 - 4 : 5 + 2) scheme@(guile-user)> '{#(1 2 3 4 5 6 7 8 9)[6 - 4 : 5 + 2]} $1 = ($bracket-apply$ #(1 2 3 4 5 6 7 8 9) 6 - 4 : 5 + 2) scheme@(guile-user)> ($bracket-apply$ #(1 2 3 4 5 6 7 8 9) 6 - 4 : 5 + 2) $bracket-apply$ : parsed-evaluated-args=((- 6 4) : (+ 5 2)) While compiling expression: Syntax error: unknown file:#f:#f: encountered raw symbol in macro output in subform - of ($bracket-apply$ #(1 2 3 4 5 6 7 8 9) 6 - 4 : 5 + 2) as you can see i have the good syntax from infix to prefix: $bracket-apply$ : parsed-evaluated-args=((- 6 4) : (+ 5 2)) how can i make the macro result be what i want, here is the actual one: (define-syntax $bracket-apply$ (lambda (stx) (syntax-case stx () (($bracket-apply$ container . args-brackets) (with-syntax ((parsed-evaluated-args (optimizer-parse-square-brackets-arguments-lister (syntax->datum #'args-brackets)))) (display "$bracket-apply$ : parsed-evaluated-args=") (display #'parsed-evaluated-args) (newline) #'($bracket-apply$next4list-args container parsed-evaluated-args)))))) a working solution was: {#(1 2 3 4 5 6 7)[2 * 5 - 8 : 3 * 5 - 10]} '#(3 4 5) {#(1 2 3 4 5 6 7)[2 * 5 - 8 : 3 * 5 - 10 : 2 * 4 - 6]} '#(3 5) scheme@(guile-user)> {#(1 2 3 4 5 6 7 8 9)[6 - 4 : 5 + 2]} $bracket-apply$ : args-brackets=(6 #<procedure - (#:optional _ _ . _)> 4 : 5 #<procedure + (#:optional _ _ . _)> 2) $1 = #(3 4 5 6 7) scheme@(guile-user)> {#(1 2 3 4 5 6 7 8 9)[2 * 3 - 4 : 2 * 5 - 3]} $bracket-apply$ : args-brackets=(2 #<procedure * (#:optional _ _ . _)> 3 #<procedure - (#:optional _ _ . _)> 4 : 2 #<procedure * (#:optional _ _ . _)> 5 #<procedure - (#:optional _ _ . _)> 3) $2 = #(3 4 5 6 7) (define ($bracket-apply$ container . args-brackets) ;; this implements a possible $bracket-apply$ as proposed in SRFI-105 ;;(display "$bracket-apply$ : args-brackets=") (display args-brackets) (newline) ;;(display "$bracket-apply$ : infix-operators-lst=") (display infix-operators-lst) (newline) ($bracket-apply$next4list-args container (optimizer-parse-square-brackets-arguments-evaluator args-brackets))) but i want to avoid optimizer-parse-square-brackets-arguments-evaluator at run time , i prefer to use optimizer-parse-square-brackets-arguments-lister at a macro stage earlier ,so not rexecuted at each computation, but this an idea, perheaps not pertinent... sorry for long, obscure mail... On Sun, May 5, 2024 at 2:48 PM Jean Abou Samra <j...@abou-samra.fr> wrote: > > > (base) mattei@mbp-touch-bar Scheme-PLUS-for-Guile % guile > > GNU Guile 3.0.8.99-f3ea8 > > Copyright (C) 1995-2022 Free Software Foundation, Inc. > > > > Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. > > This program is free software, and you are welcome to redistribute it > > under certain conditions; type `,show c' for details. > > > > Enter `,help' for help. > > scheme@(guile-user)> (define-syntax test-it > > (lambda (stx) > > (syntax-case stx () > > ((_ term1) > > (with-syntax ((var (syntax->datum #'term1))) > > #'var))))) > > scheme@(guile-user)> (test-it (+ 2 3)) > > While compiling expression: > > Syntax error: > > unknown file:#f:#f: encountered raw symbol in macro output in subform + > of > > (test-it (+ 2 3)) > > > As the error message says, your macro contains the raw symbol `term1`. > The expression (syntax->datum #'term1) is equivalent to 'term1 . > What's raising the error is not with-syntax itself, it's the fact > that a hygienic macro must return syntax objects, and a raw > symbol is not a syntax object. Kawa and Racket probably have some > fallback where the macro becomes non-hygienic when it returns > raw symbols. But R6RS makes it clear that this is not standard > Scheme. See > > https://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-13.html#node_sec_12.2 > > """ > a syntax object is: > > - a pair of syntax objects, > - a vector of syntax objects, > - a nonpair, nonvector, nonsymbol value, or > - a wrapped syntax object > """ > > """ > A transformation procedure is a procedure that must accept one argument, a > wrapped syntax object (section 12.2) representing the input, and return a > syntax > object (section 12.2) representing the output. > """ > > >