* with-syntax return error in Guile, not in Kawa or Racket @ 2024-05-05 12:36 Damien Mattei 2024-05-05 12:48 ` Jean Abou Samra 0 siblings, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-05 12:36 UTC (permalink / raw) To: guile-user hi, Guile: (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)) Kawa: (base) mattei@mbp-touch-bar Scheme-PLUS-for-Guile % kawa #|kawa:1|# (define-syntax test-it #|.....2|# #|.....3|# (lambda (stx) #|.....4|# #|.....5|# (syntax-case stx () #|.....6|# #|.....7|# ((_ term1) #|.....8|# #|.....9|# (with-syntax ((var (syntax->datum #'term1))) #|....10|# #|....11|# #'var))))) #|....12|# #|kawa:13|# (test-it (+ 2 3)) 5 Racket: Language: racket, with debugging; memory limit: 8192 MB. > (define-syntax test-it (lambda (stx) (syntax-case stx () ((_ term1) (with-syntax ((var (syntax->datum #'term1))) #'var))))) > (test-it (+ 2 3)) 5 why,why? Damien ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-05 12:36 with-syntax return error in Guile, not in Kawa or Racket Damien Mattei @ 2024-05-05 12:48 ` Jean Abou Samra 2024-05-05 13:35 ` Damien Mattei 0 siblings, 1 reply; 25+ messages in thread From: Jean Abou Samra @ 2024-05-05 12:48 UTC (permalink / raw) To: Damien Mattei, guile-user [-- Attachment #1: Type: text/plain, Size: 1725 bytes --] > (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. """ [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-05 12:48 ` Jean Abou Samra @ 2024-05-05 13:35 ` Damien Mattei 2024-05-06 7:27 ` Damien Mattei 0 siblings, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-05 13:35 UTC (permalink / raw) To: Jean Abou Samra; +Cc: guile-user 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 <jean@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. > """ > > > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-05 13:35 ` Damien Mattei @ 2024-05-06 7:27 ` Damien Mattei 2024-05-06 9:41 ` Jean Abou Samra 0 siblings, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-06 7:27 UTC (permalink / raw) To: Jean Abou Samra; +Cc: guile-user a working solution , but does not know if it follows standards of scheme: (define-syntax $bracket-apply$ (lambda (stx) (syntax-case stx () ;; scheme@(guile-user)> {#(1 2 3 4 5 6 7 8 9)[6 - 4 : 5 + 2]} ;; $bracket-apply$ : parsed-evaluated-args=#<syntax (list (- 6 4) : (+ 5 2))> ;; $1 = #(3 4 5 6 7) ;; scheme@(guile-user)> (define i 5) ;; scheme@(guile-user)> {#(1 2 3 4 5 6 7 8 9)[6 - 4 : i + 2]} ;; $bracket-apply$ : parsed-evaluated-args=#<syntax (list (- 6 4) : (+ i 2))> ;; $2 = #(3 4 5 6 7) (($bracket-apply$ container . args-brackets) (with-syntax ((parsed-evaluated-args (datum->syntax #f (cons 'list (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)))))) On Sun, May 5, 2024 at 3:35 PM Damien Mattei <damien.mattei@gmail.com> wrote: > 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 <jean@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. >> """ >> >> >> ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-06 7:27 ` Damien Mattei @ 2024-05-06 9:41 ` Jean Abou Samra 2024-05-06 10:29 ` Damien Mattei 2024-05-06 17:52 ` Damien Mattei 0 siblings, 2 replies; 25+ messages in thread From: Jean Abou Samra @ 2024-05-06 9:41 UTC (permalink / raw) To: Damien Mattei; +Cc: guile-user [-- Attachment #1: Type: text/plain, Size: 739 bytes --] > (with-syntax ((parsed-evaluated-args > (datum->syntax #f (cons 'list (optimizer-parse-square-brackets-arguments-lister > (syntax->datum #'args-brackets)))))) That should work, but it's also non-hygienic. For example, it will be affected if the user does (let ((list ...)) (call-your-macro ...)) and since you use #f in the datum->syntax call, it will also strip away all hygiene annotations from the args-brackets, causing problems inside that as well. I'd advise you refactor your optimizer-parse-square-brackets-arguments-lister function so that it takes #'args-brackets instead of (syntax->datum #'args-brackets) and works with it in a hygienic way. [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-06 9:41 ` Jean Abou Samra @ 2024-05-06 10:29 ` Damien Mattei 2024-05-06 12:03 ` Damien Mattei 2024-05-06 17:52 ` Damien Mattei 1 sibling, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-06 10:29 UTC (permalink / raw) To: Jean Abou Samra; +Cc: guile-user at any point in any scheme if the user write such a thing: (let ((list 3)) (list 4)) there will be a serious problem On Mon, May 6, 2024 at 11:41 AM Jean Abou Samra <jean@abou-samra.fr> wrote: > > (with-syntax ((parsed-evaluated-args > > (datum->syntax #f (cons 'list > (optimizer-parse-square-brackets-arguments-lister > > (syntax->datum > #'args-brackets)))))) > > That should work, but it's also non-hygienic. For example, it will > be affected if the user does > > (let ((list ...)) > (call-your-macro ...)) > > and since you use #f in the datum->syntax call, it will also strip away > all hygiene annotations from the args-brackets, causing problems inside > that as well. > > I'd advise you refactor your > optimizer-parse-square-brackets-arguments-lister > function so that it takes #'args-brackets instead of (syntax->datum > #'args-brackets) > and works with it in a hygienic way. > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-06 10:29 ` Damien Mattei @ 2024-05-06 12:03 ` Damien Mattei 0 siblings, 0 replies; 25+ messages in thread From: Damien Mattei @ 2024-05-06 12:03 UTC (permalink / raw) To: Jean Abou Samra; +Cc: guile-user about the necessity of 'list it is because optimizer-parse-square-brackets-arguments-lister return a list like this: ((- 6 4) : (+ i 2)) BUT i suspect ,as in scheme , a bit due to homoiconicity of lisp/scheme (that represent code and data the same way) that out of context ((- 6 4) : (+ i 2)) can be evaluated and interpreted as (2 : (+ i 2)) depending of i and then interpreted as (apply 2 (: (+ i 1)) but that is not what i want here and optimizer-parse-square-brackets-arguments-lister was first used in procedure , not pre-compil macro before expansion. about #f , i'm working symbolically, at this stage for optimisation, the context ,and bindings will be evaluated when the expansion of macro is done and then evaluated . Keep in mind ,all that is for testing, beta-code ,and i'm discovering new things about macro, and that my knowledge and the code could change again. If someone have concrete solution to write better code i will be glad to integrate this in my code. On Mon, May 6, 2024 at 12:29 PM Damien Mattei <damien.mattei@gmail.com> wrote: > at any point in any scheme if the user write such a thing: > (let ((list 3)) (list 4)) > there will be a serious problem > > On Mon, May 6, 2024 at 11:41 AM Jean Abou Samra <jean@abou-samra.fr> > wrote: > >> > (with-syntax ((parsed-evaluated-args >> > (datum->syntax #f (cons 'list >> (optimizer-parse-square-brackets-arguments-lister >> > (syntax->datum >> #'args-brackets)))))) >> >> That should work, but it's also non-hygienic. For example, it will >> be affected if the user does >> >> (let ((list ...)) >> (call-your-macro ...)) >> >> and since you use #f in the datum->syntax call, it will also strip away >> all hygiene annotations from the args-brackets, causing problems inside >> that as well. >> >> I'd advise you refactor your >> optimizer-parse-square-brackets-arguments-lister >> function so that it takes #'args-brackets instead of (syntax->datum >> #'args-brackets) >> and works with it in a hygienic way. >> > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-06 9:41 ` Jean Abou Samra 2024-05-06 10:29 ` Damien Mattei @ 2024-05-06 17:52 ` Damien Mattei 2024-05-06 18:58 ` Maxime Devos 1 sibling, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-06 17:52 UTC (permalink / raw) To: Jean Abou Samra; +Cc: guile-user On Mon, May 6, 2024 at 11:41 AM Jean Abou Samra <jean@abou-samra.fr> wrote: > > (with-syntax ((parsed-evaluated-args > > (datum->syntax #f (cons 'list > (optimizer-parse-square-brackets-arguments-lister > > (syntax->datum > #'args-brackets)))))) > > That should work, but it's also non-hygienic. For example, it will > be affected if the user does > > (let ((list ...)) > (call-your-macro ...)) > > and since you use #f in the datum->syntax call, it will also strip away > all hygiene annotations from the args-brackets, causing problems inside > that as well. > i changed #f to stx in the macro > > I'd advise you refactor your > optimizer-parse-square-brackets-arguments-lister > function so that it takes #'args-brackets instead of (syntax->datum > #'args-brackets) > and works with it in a hygienic way. > ^ permalink raw reply [flat|nested] 25+ messages in thread
* RE: with-syntax return error in Guile, not in Kawa or Racket 2024-05-06 17:52 ` Damien Mattei @ 2024-05-06 18:58 ` Maxime Devos 2024-05-06 21:34 ` Damien Mattei 0 siblings, 1 reply; 25+ messages in thread From: Maxime Devos @ 2024-05-06 18:58 UTC (permalink / raw) To: Damien Mattei, Jean Abou Samra; +Cc: guile-user > [...] > > That should work, but it's also non-hygienic. For example, it will > be affected if the user does > > (let ((list ...)) > (call-your-macro ...)) > >> and since you use #f in the datum->syntax call, it will also strip away >> all hygiene annotations from the args-brackets, causing problems inside >> that as well. >> >i changed #f to stx in the macro That doesn’t make it hygienic, for the reasons mentioned above. syntax (#') / quasisyntax (#`)/ unsyntax (#,) and unsyntax-splicing (#,@) your friend – they behave pretty much the same as their quote/quasiquote/... counterparts. Hygiene is usually pretty simple – just don’t do sexp things (say, quasiquote), do syntax things (quasisyntax) instead, then typically things will go well. Best regards, Maxime Devos. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-06 18:58 ` Maxime Devos @ 2024-05-06 21:34 ` Damien Mattei 2024-05-09 9:21 ` Maxime Devos 0 siblings, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-06 21:34 UTC (permalink / raw) To: Maxime Devos; +Cc: Jean Abou Samra, guile-user not sure to understand, i admit i'm testing new things for me , i try to understand macro syntax and all the stuff... reading https://www.greghendershott.com/fear-of-macros/index.html but half (or less) the way..... do you mean just replacing 'list by #'list ? i do it and it is still working at least: (define-syntax $bracket-apply$ (lambda (stx) (syntax-case stx () ;; a version that pre-compil the infix expression, should be faster;; scheme@(guile-user)> {#(1 2 3 4 5 6 7 8 9)[6 - 4 : 5 + 2]};; $bracket-apply$ : parsed-evaluated-args=#<syntax (list (- 6 4) : (+ 5 2))>;; $1 = #(3 4 5 6 7);; scheme@(guile-user)> (define i 5);; scheme@(guile-user)> {#(1 2 3 4 5 6 7 8 9)[6 - 4 : i + 2]};; $bracket-apply$ : parsed-evaluated-args=#<syntax (list (- 6 4) : (+ i 2))>;; $2 = #(3 4 5 6 7) (($bracket-apply$ container . args-brackets) (with-syntax ((parsed-evaluated-args (datum->syntax stx ; #f (cons #'list (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)))))) another strange thing perheaps related to macro is that the compile warns me always that the optimizer-parse-square-brackets-arguments-lister procedure is not found: 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)> (use-modules (Scheme+)) ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /usr/local/share/guile/site/3.0/Scheme+.scm ;;; note: source file /usr/local/share/guile/site/3.0/for_next_step.scm ;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/for_next_step.scm.go ;;; compiling /usr/local/share/guile/site/3.0/for_next_step.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/for_next_step.scm.go ;;; note: source file /usr/local/share/guile/site/3.0/growable-vector.scm ;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/growable-vector.scm.go ;;; compiling /usr/local/share/guile/site/3.0/growable-vector.scm ;;; growable-vector.scm:149:2: warning: possibly wrong number of arguments to `vector-copy' ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/growable-vector.scm.go ;;; note: source file /usr/local/share/guile/site/3.0/infix-operators.scm ;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/infix-operators.scm.go ;;; compiling /usr/local/share/guile/site/3.0/infix-operators.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/infix-operators.scm.go ;;; note: source file /usr/local/share/guile/site/3.0/overload.scm ;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/overload.scm.go ;;; compiling /usr/local/share/guile/site/3.0/overload.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/overload.scm.go ;;; note: source file /usr/local/share/guile/site/3.0/array.scm ;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/array.scm.go ;;; compiling /usr/local/share/guile/site/3.0/array.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/array.scm.go ;;; WARNING: compilation of /usr/local/share/guile/site/3.0/Scheme+.scm failed: ;;; *Unbound variable: optimizer-parse-square-brackets-arguments-lister* scheme@(guile-user)> {v <+ (vector 1 2 3 4)} scheme@(guile-user)> {v[1 : 3] <- #(-1 -2 -3 -4 -5 -6 -7)[2 : 4]} scheme@(guile-user)> v $1 = #(1 -3 -4 4) but anyway it works 🤔 On Mon, May 6, 2024 at 8:58 PM Maxime Devos <maximedevos@telenet.be> wrote: > > [...] > > > > > > That should work, but it's also non-hygienic. For example, it will > > > be affected if the user does > > > > > > (let ((list ...)) > > > (call-your-macro ...)) > > > > > >> and since you use #f in the datum->syntax call, it will also strip away > > >> all hygiene annotations from the args-brackets, causing problems inside > > >> that as well. > > >> > > > > >i changed #f to stx in the macro > > > > That doesn’t make it hygienic, for the reasons mentioned above. > > > > syntax (#') / quasisyntax (#`)/ unsyntax (#,) and unsyntax-splicing (#,@) > your friend – they behave pretty much the same as their > quote/quasiquote/... counterparts. > > > > Hygiene is usually pretty simple – just don’t do sexp things (say, > quasiquote), do syntax things (quasisyntax) instead, then typically things > will go well. > > > > Best regards, > > Maxime Devos. > ^ permalink raw reply [flat|nested] 25+ messages in thread
* RE: with-syntax return error in Guile, not in Kawa or Racket 2024-05-06 21:34 ` Damien Mattei @ 2024-05-09 9:21 ` Maxime Devos 2024-05-09 21:56 ` Damien Mattei 0 siblings, 1 reply; 25+ messages in thread From: Maxime Devos @ 2024-05-09 9:21 UTC (permalink / raw) To: Damien Mattei; +Cc: Jean Abou Samra, guile-user >do you mean just replacing 'list by #'list ? No, I mean doing that, _and_ doing the same inside this optimizer-parse-square-brackets-arguments-lister procedure and removing the syntax->datum used here. I don’t know parse-square-brackets-arguments-lister so maybe it’s not necessary here (e.g. if the code it produces doesn’t contain any identifiers), but going by the name of it, it probably is. > another strange thing perheaps related to macro is that the compile warns me always that the optimizer-parse-square-brackets-arguments-lister procedure is not found: See eval-when. It’s mentioned somewhere in the documentation of macros, perhaps close to eval-when. Best regards, Maxime DEvos ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-09 9:21 ` Maxime Devos @ 2024-05-09 21:56 ` Damien Mattei 2024-05-09 22:35 ` Jean Abou Samra 0 siblings, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-09 21:56 UTC (permalink / raw) To: Maxime Devos; +Cc: guile-user it worked now removing the syntax->datum but not in all programs , i do not know why, program it fails was overloading some operator so i think the syntax symbol of operator was not correlated with the good function overloaded. So i keep the code as is. for the cloned macro i did not succeed in other solution than duplicating the macro and replace <- by ←, stupid but it works now in all codes. In fact it is a general question, how to clone a macro? for a procedure it is more simple. a solution which does not worked: (define-syntax ← (syntax-rules () ((_ ( ) expr) (<- ( ) expr)) ((_ (var) expr) (<- (var) expr)) ((_ (brket-applynext container index ...) expr) (<- (brket-applynext container index ...) expr)) ((_ var expr) (<- var expr)) ((_ var var1 ... expr) (<- var var1 ... expr)))) notice that for each case the expression is the same as the left pattern. i hoped it should clone all the case of the original macro but it fails too i have no explaination On Thu, May 9, 2024 at 11:21 AM Maxime Devos <maximedevos@telenet.be> wrote: > >do you mean just replacing 'list by #'list ? > > > > No, I mean doing that, _and_ doing the same inside this > optimizer-parse-square-brackets-arguments-lister procedure and removing the > syntax->datum used here. > > > > I don’t know parse-square-brackets-arguments-lister so maybe it’s not > necessary here (e.g. if the code it produces doesn’t contain any > identifiers), but going by the name of it, it probably is. > > > > > another strange thing perheaps related to macro is that the compile > warns me always that the optimizer-parse-square-brackets-arguments-lister > procedure is not found: > > > > See eval-when. It’s mentioned somewhere in the documentation of macros, > perhaps close to eval-when. > > > > Best regards, > > Maxime DEvos > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-09 21:56 ` Damien Mattei @ 2024-05-09 22:35 ` Jean Abou Samra 2024-05-10 9:40 ` Damien Mattei 2024-05-15 17:44 ` Macros that don't work Keith Wright 0 siblings, 2 replies; 25+ messages in thread From: Jean Abou Samra @ 2024-05-09 22:35 UTC (permalink / raw) To: Damien Mattei; +Cc: Maxime Devos, guile-user > Le 9 mai 2024 à 23:57, Damien Mattei <damien.mattei@gmail.com> a écrit : > > it worked now removing the syntax->datum but not in all programs , i do not > know why, program it fails was overloading some operator so i think the > syntax symbol of operator was not correlated with the good function > overloaded. Sorry, I don't understand what you're trying to express here. > So i keep the code as is. > for the cloned macro i did not succeed in other solution than duplicating > the macro and replace <- by ←, stupid but it works now in all codes. > In fact it is a general question, how to clone a macro? for a procedure it > is more simple. The simple solution (define-syntax-rule (← . args) (<- . args)) should really work. Maybe you have several files and you forgot to clear the bytecode cache? Keep in mind that Guile doesn't do dependency tracking: if file B uses a macro defined in file A and file A changes, B won't be recompiled automatically, and will use the expansions from the old macros until you clear the cache or use --no-auto-compile or similar. This is the only explanation I can think of for this part of your problem. Jean ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-09 22:35 ` Jean Abou Samra @ 2024-05-10 9:40 ` Damien Mattei 2024-05-10 10:33 ` Jean Abou Samra 2024-05-15 17:44 ` Macros that don't work Keith Wright 1 sibling, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-10 9:40 UTC (permalink / raw) To: Jean Abou Samra; +Cc: Maxime Devos, guile-user On Fri, May 10, 2024 at 12:35 AM Jean Abou Samra <jean@abou-samra.fr> wrote: > > > > Le 9 mai 2024 à 23:57, Damien Mattei <damien.mattei@gmail.com> a écrit : > > > > it worked now removing the syntax->datum but not in all programs , i do > not > > know why, program it fails was overloading some operator so i think the > > syntax symbol of operator was not correlated with the good function > > overloaded. > > Sorry, I don't understand what you're trying to express here. > this was just a 5.00 AM clock assumption, so i'm not sure but : when i remove syntax->datum (see commented code below) in macro <- : ;; example: {a[4] <- 7} ;; $bracket-apply$ is from SRFI 105 $bracket-apply$ is an argument of the macro <- here ((_ (brket-applynext container index ...) expr) ; possible to have NO index : ; minimal form is (_ (brket-applynext container) expr) ;; We will let the second $bracket-apply$ be executed and forbid the execution of first $bracket-apply$. (cond ((equal? (quote $bracket-apply$next) (syntax->datum #'brket-applynext)) ;; already parsed and optimised by parser #'(assignmentnext container expr index ...)) ; possible to have NO index ;; integrated curly-infix of guile (no parsing) at REPL ((equal? (quote $bracket-apply$) (syntax->datum #'brket-applynext)) (display "<- : #'(index ...) = ") (display #'(index ...)) (newline) (display "<- : (syntax->datum #'(index ...)) = ") (display (syntax->datum #'(index ...))) (newline) ;;(display "<- : (number? (car (syntax->datum #'(index ...)))) = ") (display (number? (car (syntax->datum #'(index ...))))) (newline) ;; parse arguments at posteriori here: (with-syntax ((parsed-args (datum->syntax stx ; #f (cons #'list (optimizer-parse-square-brackets-arguments-lister (syntax->datum #'(index ...))))))) ;; (with-syntax ((parsed-args ;; (cons #'list ;; otherwise:Wrong type to apply: 0 ,list will be interpreted as code ! ;; (optimizer-parse-square-brackets-arguments-lister #'(index ...))))) (display "<- : #'parsed-args=") (display #'parsed-args) (newline) (display "<- : (syntax->datum #'parsed-args)=") (display (syntax->datum #'parsed-args)) (newline) (case (length (cdr (syntax->datum #'parsed-args))) ;;(case (length (cdr #'parsed-args)) ;;(case (length #'parsed-args) if i do this instead: (with-syntax ((parsed-args (cons #'list (optimizer-parse-square-brackets-arguments-lister #'(index ...))))) my code fails at run-time : ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/Users/mattei/AI_Deep_Learning/exo_retropropagationNhidden_layers_matrix_v2_by_vectors4guile+.scm.go ################## NOT ################## *init* : nc=#(1 2 1) z=#(#(0) #(0 0) #(0)) z̃=#(#(0) #(0 0) #(0)) M=#(#<<matrix> 10313c640> #<<matrix> 10313c560>) ᐁ=#(#(0) #(0 0) #(0)) nbiter=5000 0 ice-9/boot-9.scm:1685:16: In procedure raise-exception: In procedure <: Wrong type argument in position 1: #<procedure + (#:optional _ _ . _)> when i look at code , i can use 2 overload mechanism for + , the one of mine (Scheme+) and the one of GOOPS guile, here this one is in use: the other is commented: ;scheme@(guile-user)> {#(1 2) + #(3 4 5)} ;$1 = #(1 2 3 4 5) ;scheme@(guile-user)> {#(1 2) + #(3 4 5) + #(6 7)} ;$2 = #(1 2 3 4 5 6 7) (define-method (+ (x <vector>) (y <vector>)) (vector-append x y)) ;; ; first stage overloading ;; (define-overload-existing-operator +) ;; ; second stage overloading ;; (overload-existing-operator + vector-append (vector? vector?)) i do not understand well macro syntax features of R6RS but now all the code works > > So i keep the code as is. > > for the cloned macro i did not succeed in other solution than duplicating > > the macro and replace <- by ←, stupid but it works now in all codes. > > In fact it is a general question, how to clone a macro? for a procedure > it > > is more simple. > > The simple solution > > (define-syntax-rule (← . args) (<- . args)) > sorry, but this can not works because my macro is defined this way: (define-syntax <- (lambda (stx) (syntax-case stx () ;; silly case ((_ ( ) expr) #'(void)) ;; void is not portable ;'()) ;; one value in values ! ;; > {(x) <- (values 7)} ;; > x ;; 7 ((_ (var) expr) #'(set!-values-plus (var) expr)) etc... other case continues so my arguments are not put in a list as in your definition ok i see it is not define-syntax but define-syntax-rules, first not in R6RS, so not portable ,does not exist in Kawa: #|kawa:1|# define-syntax-rules /dev/tty:1:1: warning - no declaration seen for define-syntax-rules /dev/tty:1:1: unbound location: define-syntax-rules but i test it with my guile code,fails too at run-time: scheme@(guile-user)> (logic-test) test 1 (or (and (not a) (not b) (not c) (not d)) (and (not a) (not b) (not c) d) (and (not a) (not b) c (not d)) (and (not a) b (not c) d) (and (not a) b c (not d)) (and (not a) b c d) (and a (not b) (not c) (not d)) (and a (not b) (not c) d) (and a (not b) c (not d)) (and c (not d))) = ice-9/boot-9.scm:1685:16: In procedure raise-exception: Unbound variable: lin Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user) [1]> ,bt In /Users/mattei/library-FunctProg/guile/logiki+.scm: 2848:18 5 (_ #<continuation 101c6a500>) 743:23 4 (infix-symb-min-dnf _) 1777:41 3 (minimal-dnf _) 2707:38 2 (_ _) 2526:19 1 (identify-essential-prime-implicants _ _) In ice-9/boot-9.scm: 1685:16 0 (raise-exception _ #:continuable? _) the offending code is here: ;; construction of the array ;; set the left column containing prime implicants (for-basic (lin 0 {lgt-pi - 1}) ;;(display "lin=") (display lin) (newline) ;;(display "{vct-prime-implicants[lin]}=") (display {vct-prime-implicants[lin]}) (newline) ;;(display "{iepi[{lin + 1} 0]}=") (display {iepi[{lin + 1} 0]}) (newline) {iepi[{lin + 1} 0] ← vct-prime-implicants[lin]}) ;;{iepi[{lin + 1} 0] <- vct-prime-implicants[lin]}) ;(display "iepi after") (newline) exactly here, just in the macro: {iepi[{lin + 1} 0] ← vct-prime-implicants[lin]}) in the macro lin is not more binded, so i suppose there is a problem of hygiene, the macro wipe out the binding of lin but it works at REPL,strange ... : 1685:16 0 (raise-exception _ #:continuable? _) scheme@(guile-user) [1]> ,q scheme@(guile-user)> {v <+ (vector 1 2 3 4)} scheme@(guile-user)> {v[1 : 3] <- #(-1 -2 -3 -4 -5 -6 -7)[2 : 4]} <- : #'(index ...) = (#<syntax:unknown file:6:3 1> #<syntax:unknown file:6:5 :> #<syntax:unknown file:6:7 3>) <- : (syntax->datum #'(index ...)) = (1 : 3) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> 1 : 3)> <- : (syntax->datum #'parsed-args)=(list 1 : 3) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> 2 : 4)> scheme@(guile-user)> v $1 = #(1 -3 -4 4) scheme@(guile-user)> {v[1 : 3] ← #(-1 -2 -3 -4 -5 -6 -7)[2 : 4]} <- : #'(index ...) = (#<syntax:unknown file:8:3 1> #<syntax:unknown file:8:5 :> #<syntax:unknown file:8:7 3>) <- : (syntax->datum #'(index ...)) = (1 : 3) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> 1 : 3)> <- : (syntax->datum #'parsed-args)=(list 1 : 3) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> 2 : 4)> scheme@(guile-user)> v $2 = #(1 -3 -4 4) scheme@(guile-user)> (define lin 1) scheme@(guile-user)> {v[lin : 3] ← #(-1 -2 -3 -4 -5 -6 -7)[2 : 4]} <- : #'(index ...) = (#<syntax:unknown file:11:3 lin> #<syntax:unknown file:11:7 :> #<syntax:unknown file:11:9 3>) <- : (syntax->datum #'(index ...)) = (lin : 3) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> lin : 3)> <- : (syntax->datum #'parsed-args)=(list lin : 3) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> 2 : 4)> scheme@(guile-user)> v $3 = #(1 -3 -4 4) and even with a variable ,i defined lin in the example > should really work. Maybe you have several files and you forgot to clear > the bytecode cache? Keep in mind that Guile doesn't do dependency tracking: > if file B uses a macro defined in file A and file A changes, B won't be > recompiled automatically, and will use the expansions from the old macros > until you clear the cache or use --no-auto-compile or similar. This is the > only explanation I can think of for this part of your problem. > i know this caveit, each time i test i remove all the old modules compiled: (base) mattei@mbp-touch-bar ~ % rm -rf .cache/guile/ (base) mattei@mbp-touch-bar ~ % rm -rf .cache/guile/ (base) mattei@mbp-touch-bar ~ % rm -rf .cache/guile/ (base) mattei@mbp-touch-bar ~ % rm -rf .cache/guile/ (base) mattei@mbp-touch-bar ~ % rm -rf .cache/guile/ (base) mattei@mbp-touch-bar ~ % rm -rf .cache/guile/ (base) mattei@mbp-touch-bar ~ % rm -rf .cache/guile/ so the guile compiler find a clean system,output of a compile: note that the compiler find the problem with unbound variables: ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:2526:19: warning: possibly unbound variable `lin' ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:2546:18: warning: possibly unbound variable `col' ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:2554:13: warning: possibly unbound variable `lin-pos-epi' if i no more use your macro it works: 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)> (load "start-λογικι-guile+.scm") ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /Users/mattei/library-FunctProg/start-λογικι-guile+.scm ;;; compiling /usr/local/share/guile/site/3.0/Scheme+.scm ;;; compiling /usr/local/share/guile/site/3.0/for_next_step.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/for_next_step.scm.go ;;; compiling /usr/local/share/guile/site/3.0/growable-vector.scm ;;; growable-vector.scm:149:2: warning: possibly wrong number of arguments to `vector-copy' ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/growable-vector.scm.go ;;; compiling /usr/local/share/guile/site/3.0/infix-operators.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/infix-operators.scm.go ;;; compiling /usr/local/share/guile/site/3.0/overload.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/overload.scm.go ;;; compiling /usr/local/share/guile/site/3.0/array.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/array.scm.go ;;; compiling /usr/local/share/guile/site/3.0/condx.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/condx.scm.go <- : #'(index ...) = (#<syntax:assignment.scm:1288:68 i1> #<syntax:assignment.scm:1288:71 slice> #<syntax:assignment.scm:1288:77 i2>) <- : (syntax->datum #'(index ...)) = (i1 slice i2) ;;; WARNING: compilation of /usr/local/share/guile/site/3.0/Scheme+.scm failed: ;;; Unbound variable: optimizer-parse-square-brackets-arguments-lister <- : #'(index ...) = (#<syntax:assignment.scm:1288:68 i1> #<syntax:assignment.scm:1288:71 slice> #<syntax:assignment.scm:1288:77 i2>) <- : (syntax->datum #'(index ...)) = (i1 slice i2) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> i1 slice i2)> <- : (syntax->datum #'parsed-args)=(list i1 slice i2) ;;; compiling /usr/local/share/guile/site/3.0/operation+.scm ;;; compiling /usr/local/share/guile/site/3.0/set+.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/set+.scm.go ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/operation+.scm.go ;;; compiling /usr/local/share/guile/site/3.0/minterms+.scm ;;; binary-arithmetic.scm:239:2: warning: "~24,'0,':b": wrong port argument ;;; binary-arithmetic.scm:248:3: warning: "~24,' ,':b": wrong port argument ;;; simplify.scm:52:31: warning: possibly unbound variable `zero-symb?' ;;; simplify.scm:115:37: warning: possibly unbound variable `unity-symb?' ;;; binary-arithmetic.scm:257:6: warning: possibly unbound variable `bitwise-and' ;;; binary-arithmetic.scm:271:16: warning: possibly unbound variable `arithmetic-shift' ;;; minterms+.scm:419:17: warning: possibly unbound variable `segment-start' ;;; minterms+.scm:420:15: warning: possibly unbound variable `segment-end' ;;; minterms+.scm:422:31: warning: possibly unbound variable `minterms-vector' ;;; minterms+.scm:425:9: warning: possibly unbound variable `unified-minterms-vector-1' ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/minterms+.scm.go ;;; compiling /usr/local/share/guile/site/3.0/subscript+.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/subscript+.scm.go ;;; compiling /usr/local/share/guile/site/3.0/regex+.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/regex+.scm.go $nfx$ : parsed-args=#<syntax (<- ztest (+ (* 3 5) ztest))> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $nfx$ : parsed-args=#<syntax (<- zorglub (+ zorglub (* 3 5) 2))> <- : #'(index ...) = (#<syntax:logiki+.scm:2390:34 e>) <- : (syntax->datum #'(index ...)) = (e) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> e)> <- : (syntax->datum #'parsed-args)=(list e) <- : #'(index ...) = (#<syntax:logiki+.scm:2413:17 mt1>) <- : (syntax->datum #'(index ...)) = (mt1) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> mt1)> <- : (syntax->datum #'parsed-args)=(list mt1) <- : #'(index ...) = (#<syntax:logiki+.scm:2414:17 mt2>) <- : (syntax->datum #'(index ...)) = (mt2) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> mt2)> <- : (syntax->datum #'parsed-args)=(list mt2) <- : #'(index ...) = (#<syntax:logiki+.scm:2446:18 e>) <- : (syntax->datum #'(index ...)) = (e) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> e)> <- : (syntax->datum #'parsed-args)=(list e) ← : #'(index ...) = (#<syntax:logiki+.scm:2511:8 0>) ← : (syntax->datum #'(index ...)) = (0) ← : #'parsed-args=#<syntax (#<syntax:assignment.scm:400:64 list> 0)> ← : (syntax->datum #'parsed-args)=(list 0) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> lin 0)> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> lin col)> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> lin col)> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> 0 col)> ← : #'(index ...) = (#<syntax:logiki+.scm:2554:19 lin-pos-epi> #<syntax:logiki+.scm:2554:31 col>) ← : (syntax->datum #'(index ...)) = (lin-pos-epi col) ← : #'parsed-args=#<syntax (#<syntax:assignment.scm:400:64 list> lin-pos-epi col)> ← : (syntax->datum #'parsed-args)=(list lin-pos-epi col) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> lin-pos-epi 0)> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> lin 0)> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> 0 col)> ← : #'(index ...) = (#<syntax:logiki+.scm:2546:24 lin> #<syntax:logiki+.scm:2546:28 col>) ← : (syntax->datum #'(index ...)) = (lin col) ← : #'parsed-args=#<syntax (#<syntax:assignment.scm:400:64 list> lin col)> ← : (syntax->datum #'parsed-args)=(list lin col) ← : #'(index ...) = (#<syntax:logiki+.scm:2550:22 lin> #<syntax:logiki+.scm:2550:26 col>) ← : (syntax->datum #'(index ...)) = (lin col) ← : #'parsed-args=#<syntax (#<syntax:assignment.scm:400:64 list> lin col)> ← : (syntax->datum #'parsed-args)=(list lin col) ← : #'(index ...) = (#<syntax:logiki+.scm:2526:19 (#<syntax:logiki+.scm:2526:24 +> #<syntax:logiki+.scm:2526:20 lin> #<syntax:logiki+.scm:2526:26 1>)> #<syntax:logiki+.scm:2526:29 0>) ← : (syntax->datum #'(index ...)) = ((+ lin 1) 0) ← : #'parsed-args=#<syntax (#<syntax:assignment.scm:400:64 list> (+ lin 1) 0)> ← : (syntax->datum #'parsed-args)=(list (+ lin 1) 0) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> lin)> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> lin col)> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> lin 0)> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> 0 col)> <- : #'(index ...) = (#<syntax:logiki+.scm:3130:21 mt1>) <- : (syntax->datum #'(index ...)) = (mt1) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> mt1)> <- : (syntax->datum #'parsed-args)=(list mt1) <- : #'(index ...) = (#<syntax:logiki+.scm:3131:21 mt2>) <- : (syntax->datum #'(index ...)) = (mt2) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> mt2)> <- : (syntax->datum #'parsed-args)=(list mt2) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> <- : #'(index ...) = (#<syntax:logiki+.scm:3140:29 i>) <- : (syntax->datum #'(index ...)) = (i) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> i)> <- : (syntax->datum #'parsed-args)=(list i) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> <- : #'(index ...) = (#<syntax:logiki+.scm:3150:29 i>) <- : (syntax->datum #'(index ...)) = (i) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> i)> <- : (syntax->datum #'parsed-args)=(list i) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> <- : #'(index ...) = (#<syntax:logiki+.scm:3240:34 i>) <- : (syntax->datum #'(index ...)) = (i) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> i)> <- : (syntax->datum #'parsed-args)=(list i) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> <- : #'(index ...) = (#<syntax:logiki+.scm:3611:27 i>) <- : (syntax->datum #'(index ...)) = (i) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> i)> <- : (syntax->datum #'parsed-args)=(list i) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> <- : #'(index ...) = (#<syntax:logiki+.scm:3613:38 i>) <- : (syntax->datum #'(index ...)) = (i) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> i)> <- : (syntax->datum #'parsed-args)=(list i) $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> <- : #'(index ...) = (#<syntax:logiki+.scm:3666:13 i>) <- : (syntax->datum #'(index ...)) = (i) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> i)> <- : (syntax->datum #'parsed-args)=(list i) $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> <- : #'(index ...) = (#<syntax:logiki+.scm:3646:13 i>) <- : (syntax->datum #'(index ...)) = (i) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> i)> <- : (syntax->datum #'parsed-args)=(list i) $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> i)> $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> <- : #'(index ...) = (#<syntax:logiki+.scm:3620:13 i>) <- : (syntax->datum #'(index ...)) = (i) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> i)> <- : (syntax->datum #'parsed-args)=(list i) $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> $nfx$ : parsed-args=#<syntax (<- i (+ i 1))> $nfx$ : parsed-args=#<syntax (+ (* 3 n) 1)> $nfx$ : parsed-args=#<syntax (+ (* x x x) c)> <- : #'(index ...) = (#<syntax:logiki+.scm:4364:17 mt1>) <- : (syntax->datum #'(index ...)) = (mt1) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> mt1)> <- : (syntax->datum #'parsed-args)=(list mt1) <- : #'(index ...) = (#<syntax:logiki+.scm:4365:17 mt2>) <- : (syntax->datum #'(index ...)) = (mt2) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> mt2)> <- : (syntax->datum #'parsed-args)=(list mt2) $nfx$ : parsed-args=#<syntax (+ (* 3 (quote (1 2 3))) (quote (4 5 6)) (quote (7 8 9)))> $bracket-apply$ : parsed-args=#<syntax (#<syntax:apply-square-brackets.scm:107:57 list> (+ (- (* 2 3) 4) 2))> $nfx$ : parsed-args=#<syntax (+ (* 3 (quote (1 2 3))) (quote (4 5 6)) (quote (7 8 9)))> $nfx$ : parsed-args=#<syntax (<- x (+ 1 x (* 4 5)))> <- : #'(index ...) = (#<syntax:start-λογικι-guile+.scm:225:22 k>) <- : (syntax->datum #'(index ...)) = (k) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> k)> <- : (syntax->datum #'parsed-args)=(list k) ;;; /Users/mattei/library-FunctProg/start-λογικι-guile+.scm:109:0: warning: shadows previous definition of `length' at /Users/mattei/library-FunctProg/start-λογικι-guile+.scm:108:0 ;;; /Users/mattei/library-FunctProg/start-λογικι-guile+.scm:151:0: warning: shadows previous definition of `area' at /Users/mattei/library-FunctProg/start-λογικι-guile+.scm:142:0 ;;; /Users/mattei/library-FunctProg/start-λογικι-guile+.scm:152:0: warning: shadows previous definition of `area' at /Users/mattei/library-FunctProg/start-λογικι-guile+.scm:142:0 ;;; /Users/mattei/library-FunctProg/start-λογικι-guile+.scm:190:0: warning: shadows previous definition of `qproc-14b99c8e39d8193a' at /Users/mattei/library-FunctProg/start-λογικι-guile+.scm:142:0 ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:3650:3: warning: possibly unbound variable `openmp' ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:3650:27: warning: possibly unbound variable `string->pointer' ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:3670:3: warning: possibly unbound variable `forfunct' ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:3974:33: warning: possibly unbound variable `parallel-vector-map' ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/Users/mattei/library-FunctProg/start-λογικι-guile+.scm.go create-overloaded-procedure : pred-list = (#<procedure vector? (_)>) funct: #<procedure vector-length (_)> orig-funct: #<procedure length (_)> old-funct: #<procedure length (_)> new-funct: #<procedure new-funct args> create-overloaded-procedure : pred-list = (#<procedure string? (_)>) funct: #<procedure string-length (_)> orig-funct: #<procedure new-funct args> old-funct: #<procedure new-funct args> new-funct: #<procedure new-funct args> create-overloaded-procedure : pred-list = (#<procedure number? (_)>) funct: #<procedure surf-carre-parfait (x)> orig-funct: #<procedure area args-lst> old-funct: #<procedure area args-lst> new-funct: #<procedure new-funct args> create-overloaded-procedure : pred-list = (#<procedure number? (_)> #<procedure number? (_)>) funct: #<procedure surf-carre-long (x y)> orig-funct: #<procedure new-funct args> old-funct: #<procedure new-funct args> new-funct: #<procedure new-funct args> before add-list-list before overload-existing-n-arity-operator create-overloaded-existing-n-arity-operator : pred-list = (#<procedure list? (_)> #<procedure list? (_)>) orig-funct = #<procedure + (#:optional _ _ . _)> funct = #<procedure add-n-lists vn-lst> funct: #<procedure add-n-lists vn-lst> orig-funct: #<procedure + (#:optional _ _ . _)> old-funct: #<procedure + (#:optional _ _ . _)> new-funct: #<procedure new-funct args> replace-operator! : (0 (#<procedure expt (_ _)> #<procedure expt (_ _)>) (#<procedure * (#:optional _ _ . _)> #<procedure / (#:optional _ _ . _)> #<procedure modulo (_ _)>) (#<procedure + (#:optional _ _ . _)> #<procedure - (#:optional _ _ . _)>) (#<procedure << (x n)> #<procedure >> (x n)>) (#<procedure logand (#:optional _ _ . _)> #<procedure logior (#:optional _ _ . _)>) (#<procedure < (#:optional _ _ . _)> #<procedure > (#:optional _ _ . _)> #<procedure = (#:optional _ _ . _)> #<procedure ≠ (x y)> #<procedure <= (#:optional _ _ . _)> #<procedure >= (#:optional _ _ . _)>)) (1 (#<procedure expt (_ _)> #<procedure expt (_ _)>) (#<procedure * (#:optional _ _ . _)> #<procedure / (#:optional _ _ . _)> #<procedure modulo (_ _)>) (#<procedure new-funct args> #<procedure - (#:optional _ _ . _)>) (#<procedure << (x n)> #<procedure >> (x n)>) (#<procedure logand (#:optional _ _ . _)> #<procedure logior (#:optional _ _ . _)>) (#<procedure < (#:optional _ _ . _)> #<procedure > (#:optional _ _ . _)> #<procedure = (#:optional _ _ . _)> #<procedure ≠ (x y)> #<procedure <= (#:optional _ _ . _)> #<procedure >= (#:optional _ _ . _)>)) before mult-num-list create-overloaded-existing-operator : pred-list = (#<procedure number? (_)> #<procedure list? (_)>) funct: #<procedure mult-num-list (k v)> orig-funct: #<procedure * (#:optional _ _ . _)> old-funct: #<procedure * (#:optional _ _ . _)> new-funct: #<procedure new-funct args> replace-operator! : (1 (#<procedure expt (_ _)> #<procedure expt (_ _)>) (#<procedure * (#:optional _ _ . _)> #<procedure / (#:optional _ _ . _)> #<procedure modulo (_ _)>) (#<procedure new-funct args> #<procedure - (#:optional _ _ . _)>) (#<procedure << (x n)> #<procedure >> (x n)>) (#<procedure logand (#:optional _ _ . _)> #<procedure logior (#:optional _ _ . _)>) (#<procedure < (#:optional _ _ . _)> #<procedure > (#:optional _ _ . _)> #<procedure = (#:optional _ _ . _)> #<procedure ≠ (x y)> #<procedure <= (#:optional _ _ . _)> #<procedure >= (#:optional _ _ . _)>)) (2 (#<procedure expt (_ _)> #<procedure expt (_ _)>) (#<procedure new-funct args> #<procedure / (#:optional _ _ . _)> #<procedure modulo (_ _)>) (#<procedure new-funct args> #<procedure - (#:optional _ _ . _)>) (#<procedure << (x n)> #<procedure >> (x n)>) (#<procedure logand (#:optional _ _ . _)> #<procedure logior (#:optional _ _ . _)>) (#<procedure < (#:optional _ _ . _)> #<procedure > (#:optional _ _ . _)> #<procedure = (#:optional _ _ . _)> #<procedure ≠ (x y)> #<procedure <= (#:optional _ _ . _)> #<procedure >= (#:optional _ _ . _)>)) define-overload-operator : proc =#<procedure *b args-lst> 16 (14 19 24) 5 V=#(-1 -1 -1 -1 -1 -1 #<unspecified> #<unspecified> #<unspecified> #<unspecified>) scheme@(guile-user)> (logic-test) test 1 (or (and (not a) (not b) (not c) (not d)) (and (not a) (not b) (not c) d) (and (not a) (not b) c (not d)) (and (not a) b (not c) d) (and (not a) b c (not d)) (and (not a) b c d) (and a (not b) (not c) (not d)) (and a (not b) (not c) d) (and a (not b) c (not d)) (and c (not d))) = ((¬a ∧ b ∧ d) ∨ (¬b ∧ ¬c) ∨ (c ∧ ¬d)) EXACT test 2 (or (and (not a) (not b) (not c) (not d)) (and (not a) (not b) (not c) d) (and (not a) (not b) c (not d)) (and (not a) b (not c) d) (and (not a) b c (not d)) (and (not a) b c d) (and a (not b) (not c) (not d)) (and a (not b) (not c) d) (and a (not b) c (not d)) (and c (not d))) = ((¬a ∧ b ∧ d) ∨ (¬b ∧ ¬c) ∨ (c ∧ ¬d)) EXACT test 3 (or (and (and A B) (not (and C (or (and A (not B)) (and (not A) B))))) (and (not (and A B)) (and C (or (and A (not B)) (and (not A) B))))) = ((A ∧ B) ∨ (A ∧ C) ∨ (B ∧ C)) EXACT test 4 (⊕ (· B1 B0) (· C1 (⊕ B1 B0))) = ((B0 ∧ B1) ∨ (B0 ∧ C1) ∨ (B1 ∧ C1)) EXACT test 5 (or (and B3 (or B2 (and (not B12) B3))) (and B4 (or B2 (and (not B12) B3)))) = (or (and B2 B3) (and B2 B4) (and B3 (not B12))) EXACT test 6 (or (and (not a) (not b) (not c) (not d)) (and (not a) (not b) (not c) d) (and (not a) (not b) c (not d)) (and (not a) b (not c) d) (and (not a) b c (not d)) (and (not a) b c d) (and a (not b) (not c) (not d)) (and a (not b) (not c) d) (and a (not b) c (not d)) (and c (not d))) = ((¬a ∨ ¬b ∨ c) ∧ (¬a ∨ ¬b ∨ ¬d) ∧ (¬a ∨ ¬c ∨ ¬d) ∧ (b ∨ ¬c ∨ ¬d) ∧ (¬b ∨ c ∨ d)) EXACT test 7 (or (and (and A B) (not (and C (or (and A (not B)) (and (not A) B))))) (and (not (and A B)) (and C (or (and A (not B)) (and (not A) B))))) = (or (and A B C) (and A B (not C)) (and A (not B) C) (and (not A) B C)) EXACT test 8 (or (and B₃ (or B₂ (and (not B₁₂) B₃))) (and B₄ (or B₂ (and (not B₁₂) B₃)))) = (or (and B₂ B₃) (and B₂ B₄) (and B₃ (not B₁₂))) EXACT $1 = #t but there is sill false warnings in guile in the output: > ;;; WARNING: compilation of /usr/local/share/guile/site/3.0/Scheme+.scm > failed: > ;;; Unbound variable: optimizer-parse-square-brackets-arguments-lister > without Scheme+ and optimizer-parse-square-brackets-arguments-lister the code would fail at startup as you say perheaps eval-when can help : https://www.gnu.org/software/guile/manual/html_node/Eval-When.html but i do not know how,and again this not portable , i have not port this part of code to Kawa or Racket (problem is different Kawa have no curly infix mode and Racket ,i use a #lang reader but i have a mode to emulate SRFI 105 only parser without scheme+ features) for now all my code : logic computation, deep learning example, and another private one works with the latest version of Scheme+ , so as it runs again on more that 10000 lines of code i think it is stable enought to release it soon after a few more tests. There is no new features, i just migrate a lot of parser features in the macro system so it should run all code in curly-mode without no more need to parse code in command line. best wishes, Damien > Jean > > > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-10 9:40 ` Damien Mattei @ 2024-05-10 10:33 ` Jean Abou Samra 2024-05-10 13:52 ` Damien Mattei 0 siblings, 1 reply; 25+ messages in thread From: Jean Abou Samra @ 2024-05-10 10:33 UTC (permalink / raw) To: Damien Mattei; +Cc: Maxime Devos, guile-user [-- Attachment #1: Type: text/plain, Size: 5524 bytes --] > sorry, but this can not works because my macro is defined this way: > (define-syntax <- > (lambda (stx) > (syntax-case stx () > ;; silly case > ((_ ( ) expr) > #'(void)) ;; void is not portable ;'()) > ;; one value in values ! > ;; > {(x) <- (values 7)} > ;; > x > ;; 7 > ((_ (var) expr) > #'(set!-values-plus (var) expr)) > > etc... other case continues > > so my arguments are not put in a list as in your definition. That has no influence whatsoever. The macro ← just replaces itself with <- and then <- does its job as usual. For example, this works perfectly: (define-syntax <- (syntax-rules () ((<- foo bar) (set! foo bar)) ((<- foo) (set! foo #f)))) (define-syntax-rule (← . args) (<- . args)) (define a 5) (← a 7) (display a) (newline) (← a) (display a) (newline) It is similar to how you can alias a procedure with (define alias (lambda args (apply old-procedure args))) > > ok i see it is not define-syntax but define-syntax-rules, first not in R6RS, > so not portable ,does not exist in Kawa: > #|kawa:1|# define-syntax-rules > /dev/tty:1:1: warning - no declaration seen for define-syntax-rules > /dev/tty:1:1: unbound location: define-syntax-rules OK, make that (define-syntax ← (syntax-rules () ((← . args) (<- . args)))) define-syntax-rule is merely a shortcut for syntax-rules macros with just one rule like this (but it's indeed no standard). > but i test it with my guile code,fails too at run-time: > scheme@(guile-user)> (logic-test) > test 1 > (or (and (not a) (not b) (not c) (not d)) (and (not a) (not b) (not c) d) > (and > (not a) (not b) c (not d)) (and (not a) b (not c) d) (and (not a) b c (not > d)) > (and (not a) b c d) (and a (not b) (not c) (not d)) (and a (not b) (not c) > d) > (and a (not b) c (not d)) (and c (not d))) = ice-9/boot-9.scm:1685:16: In > procedure raise-exception: > Unbound variable: lin > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > scheme@(guile-user) [1]> ,bt > In /Users/mattei/library-FunctProg/guile/logiki+.scm: > 2848:18 5 (_ #<continuation 101c6a500>) > 743:23 4 (infix-symb-min-dnf _) > 1777:41 3 (minimal-dnf _) > 2707:38 2 (_ _) > 2526:19 1 (identify-essential-prime-implicants _ _) > In ice-9/boot-9.scm: > 1685:16 0 (raise-exception _ #:continuable? _) > > the offending code is here: > > ;; construction of the array > ;; set the left column containing prime implicants > (for-basic (lin 0 {lgt-pi - 1}) > ;;(display "lin=") (display lin) (newline) > ;;(display "{vct-prime-implicants[lin]}=") (display > {vct-prime-implicants[lin]}) (newline) > ;;(display "{iepi[{lin + 1} 0]}=") (display {iepi[{lin + 1} 0]}) > (newline) > {iepi[{lin + 1} 0] ← vct-prime-implicants[lin]}) > ;;{iepi[{lin + 1} 0] <- vct-prime-implicants[lin]}) > > ;(display "iepi after") (newline) > > exactly here, just in the macro: > {iepi[{lin + 1} 0] ← vct-prime-implicants[lin]}) > in the macro lin is not more binded, so i suppose there is a problem of > hygiene, the macro wipe out the binding of lin > > but it works at REPL,strange ... : > > 1685:16 0 (raise-exception _ #:continuable? _) > scheme@(guile-user) [1]> ,q > scheme@(guile-user)> {v <+ (vector 1 2 3 4)} > scheme@(guile-user)> {v[1 : 3] <- #(-1 -2 -3 -4 -5 -6 -7)[2 : 4]} > <- : #'(index ...) = (#<syntax:unknown file:6:3 1> #<syntax:unknown file:6:5 > :> #<syntax:unknown file:6:7 3>) > <- : (syntax->datum #'(index ...)) = (1 : 3) > <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> 1 : 3)> > <- : (syntax->datum #'parsed-args)=(list 1 : 3) > $bracket-apply$ : parsed-args=#<syntax > (#<syntax:apply-square-brackets.scm:107:57 list> 2 : 4)> > scheme@(guile-user)> v > $1 = #(1 -3 -4 4) > scheme@(guile-user)> {v[1 : 3] ← #(-1 -2 -3 -4 -5 -6 -7)[2 : 4]} > <- : #'(index ...) = (#<syntax:unknown file:8:3 1> #<syntax:unknown file:8:5 > :> #<syntax:unknown file:8:7 3>) > <- : (syntax->datum #'(index ...)) = (1 : 3) > <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> 1 : 3)> > <- : (syntax->datum #'parsed-args)=(list 1 : 3) > $bracket-apply$ : parsed-args=#<syntax > (#<syntax:apply-square-brackets.scm:107:57 list> 2 : 4)> > scheme@(guile-user)> v > $2 = #(1 -3 -4 4) > scheme@(guile-user)> (define lin 1) > scheme@(guile-user)> {v[lin : 3] ← #(-1 -2 -3 -4 -5 -6 -7)[2 : 4]} > <- : #'(index ...) = (#<syntax:unknown file:11:3 lin> #<syntax:unknown > file:11:7 :> #<syntax:unknown file:11:9 3>) > <- : (syntax->datum #'(index ...)) = (lin : 3) > <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> lin : 3)> > <- : (syntax->datum #'parsed-args)=(list lin : 3) > $bracket-apply$ : parsed-args=#<syntax > (#<syntax:apply-square-brackets.scm:107:57 list> 2 : 4)> > scheme@(guile-user)> v > $3 = #(1 -3 -4 4) > > and even with a variable ,i defined lin in the example Hard to tell with so much code and without context on what you're trying to do, but this might be caused precisely by stripping identifier annotations. Consider: (define-syntax mac (lambda (sintax) (syntax-case sintax () ((mac arg) (datum->syntax #f (syntax->datum #'arg)))))) ;; Works: ;; (define lin 6) ;; (display (mac lin)) ;; Fails (as expected): (let ((lin 5)) (display (mac lin))) [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-10 10:33 ` Jean Abou Samra @ 2024-05-10 13:52 ` Damien Mattei 2024-05-10 15:24 ` Jean Abou Samra 0 siblings, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-10 13:52 UTC (permalink / raw) To: Jean Abou Samra; +Cc: Maxime Devos, guile-user i re-test all, and your are right this working: (define-syntax foo (syntax-rules () ((foo . args) (display 'args)))) (define-syntax bar (syntax-rules () ((bar . args) (foo . args)))) (foo 1 2 3) (1 2 3) (bar 1 2 3) (1 2 3) (foo 1) (1) (bar 1) (1) (define-syntax my-macro (syntax-rules () ((my-macro arg ...) (begin (display arg) ...)))) (define-syntax bar-my-macro (syntax-rules () ((bar-my-macro . args) (my-macro . args)))) still working: (my-macro 1 2 3) 123 (bar-my-macro 1 2 3) 123 but there should be something different with my macro and code because if i put: (define-syntax ← (syntax-rules () ((← . args) (<- . args)))) in my code i get again the warnings at compilation: ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:2526:19: warning: possibly unbound variable `lin' ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:2546:18: warning: possibly unbound variable `col' ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:2554:13: warning: possibly unbound variable `lin-pos-epi' and the error at runtime: scheme@(guile-user)> (logic-test) test 1 (or (and (not a) (not b) (not c) (not d)) (and (not a) (not b) (not c) d) (and (not a) (not b) c (not d)) (and (not a) b (not c) d) (and (not a) b c (not d)) (and (not a) b c d) (and a (not b) (not c) (not d)) (and a (not b) (not c) d) (and a (not b) c (not d)) (and c (not d))) = ice-9/boot-9.scm:1685:16: In procedure raise-exception: Unbound variable: lin Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user) [1]> so strictly talking it is not the same thing as calling ← defined like this: (define-syntax ← (syntax-rules () ((← . args) (<- . args)))) and not the same as calling ← defined like this: (define-syntax ← (lambda (stx) (syntax-case stx () ;; silly case ((_ ( ) expr) #'(void)) ;; void is not portable ;'()) ;; one value in values ! ;; > {(x) ← (values 7)} ;; > x ;; 7 ((_ (var) expr) #'(set!-values-plus (var) expr)) ;; example: {a[4] ← 7} ;; $bracket-apply$ is from SRFI 105 bracket-apply is an argument of the macro ((_ (brket-applynext container index ...) expr) ; possible to have NO index : ; minimal form is (_ (brket-applynext container) expr) ;; We will let the second $bracket-apply$ be executed and forbid the execution of first $bracket-apply$. (cond ((equal? (quote $bracket-apply$next) (syntax->datum #'brket-applynext)) ;; already parsed and optimised by parser #'(assignmentnext container expr index ...)) ; possible to have NO index ;; integrated curly-infix of guile (no parsing) at REPL ((equal? (quote $bracket-apply$) (syntax->datum #'brket-applynext)) (display "← : #'(index ...) = ") (display #'(index ...)) (newline) (display "← : (syntax->datum #'(index ...)) = ") (display (syntax->datum #'(index ...))) (newline) ;;(display "← : (number? (car (syntax->datum #'(index ...)))) = ") (display (number? (car (syntax->datum #'(index ...))))) (newline) ;; parse arguments at posteriori here: (with-syntax ((parsed-args (datum->syntax stx ; #f (cons #'list (optimizer-parse-square-brackets-arguments-lister (syntax->datum #'(index ...))))))) ;; (with-syntax ((parsed-args ;; (cons #'list ;; otherwise:Wrong type to apply: 0 ,list will be interpreted as code ! ;; (optimizer-parse-square-brackets-arguments-lister #'(index ...))))) (display "← : #'parsed-args=") (display #'parsed-args) (newline) (display "← : (syntax->datum #'parsed-args)=") (display (syntax->datum #'parsed-args)) (newline) (case (length (cdr (syntax->datum #'parsed-args))) ;;(case (length (cdr #'parsed-args)) ;;(case (length #'parsed-args) ;; 0 argument in [] ;; T[] ;; {v[] ← #(1 2 3)} ;; > v ;;'#(1 2 3) ((0) #'(assignment-argument-0 container expr)) ; possible to have NO index ;; 1 argument in [ ] ;; T[index] ((1) #'(assignment-argument-1 container (first parsed-args) expr)) ;; 2 arguments in [ ] ;; ex: T[i1 :] , T[: i2], T[i1 i2] , T[: :] ;; {#(1 2 3 4 5)[inexact->exact(floor(2.7)) :]} ;; '#(3 4 5) ((2) #'(assignment-argument-2 container (first parsed-args) (second parsed-args) expr)) ;; 3 arguments in [ ] ;; T[i1 : i2] , T[i1 i2 i3] , T[: : s] ((3) #'(assignment-argument-3 container (first parsed-args) (second parsed-args) (third parsed-args) expr)) ;; 4 arguments in [ ] ;; T[: i2 : s] , T[i1 : : s] , T[i1 : i3 :] , T[i1 i2 i3 i4] ((4) #'(assignment-argument-4 container (first parsed-args) (second parsed-args) (third parsed-args) (fourth parsed-args) expr)) ;; 5 arguments in [ ] ;; T[i1 : i3 : s] , T[i1 i2 i3 i4 i5] ((5) #'(assignment-argument-5 container (first parsed-args) (second parsed-args) (third parsed-args) (fourth parsed-args) (fifth parsed-args) expr)) ;; more than 5 arguments in [ ] ;; T[i1 i2 i3 i4 i5 i6 ...] (else ; case #'(assignment-argument-6-and-more container parsed-args expr))))) (else ; cond #'(set!-values-plus (brket-applynext container index ...) expr)))) ; warning: the argument's names does not match the use ;;(← x 5) ((_ var expr) #'(set! var expr)) ;; (declare x y z t) ;; {x ← y ← z ← t ← 7} ;; 7 ;; (list x y z t) ;; (7 7 7 7) ;; > (require srfi/25) ;; > {I ← (make-array (shape 0 4 0 4))} ;; #<array:srfi-9-record-type-descriptor> ;; > {I[0 0] ← I[1 1] ← I[2 2] ← I[3 3] ← 1} ;; 1 ;; > {I[0 0]} ;; 1 ;; > {I[0 1]} ;; 0 ;; > I ;; #<array:srfi-9-record-type-descriptor> ;; > (declare a b c d) ;; > {(a b) ← (c d) ← (values 5 7)} ;; > a ;; 5 ;; > b ;; 7 ;; > c ;; 5 ;; > d ;; 7 ;; without declare: ;; > {(a b) ← (c d) ← (values 5 7)} ;; > (list a b c d) ;; '(5 7 5 7) ((_ var var1 ... expr) #'(begin ;; i do not do what the syntax says (assignation not in the good order) but it gives the same result ;;(display "← : case (_ var var1 ... expr)") (newline) (define return-values-of-expr (create-return-values expr)) (← var (return-values-of-expr)) ;;(display "← : case : passed (← var expr)") (newline) ;;(display "← : case : var=") (display var) (newline) (← var1 (return-values-of-expr)) ...)) ))) even if the version above of ← is the same as <- ,i just replaced at any place <- by ← i have no explains. I suppose there is something hard too understand with the macro syntax system. i even tried this : (define-syntax ← (syntax-rules () ((_ ( ) expr) (<- ( ) expr)) ((_ (var) expr) (<- (var) expr)) ((_ (brket-applynext container index ...) expr) (<- (brket-applynext container index ...) expr)) ((_ var expr) (<- var expr)) ((_ var var1 ... expr) (<- var var1 ... expr)))) to better respect the pattern of <- it fails too when call from ← when i will port this version of scheme+ to kawa or racket i will check all this again to see if it is a problem related to guile or scheme (but with kawa or racket i will have no support for curly-infix so the problem could be different...) On Fri, May 10, 2024 at 12:33 PM Jean Abou Samra <jean@abou-samra.fr> wrote: > > > sorry, but this can not works because my macro is defined this way: > > (define-syntax <- > > (lambda (stx) > > (syntax-case stx () > > ;; silly case > > ((_ ( ) expr) > > #'(void)) ;; void is not portable ;'()) > > ;; one value in values ! > > ;; > {(x) <- (values 7)} > > ;; > x > > ;; 7 > > ((_ (var) expr) > > #'(set!-values-plus (var) expr)) > > > > etc... other case continues > > > > so my arguments are not put in a list as in your definition. > > > That has no influence whatsoever. The macro ← just replaces > itself with <- and then <- does its job as usual. > > For example, this works perfectly: > > (define-syntax <- > (syntax-rules () > ((<- foo bar) (set! foo bar)) > ((<- foo) (set! foo #f)))) > > (define-syntax-rule (← . args) (<- . args)) > > (define a 5) > (← a 7) > (display a) (newline) > (← a) > (display a) (newline) > > > It is similar to how you can alias a procedure with > > (define alias (lambda args (apply old-procedure args))) > > > > > > ok i see it is not define-syntax but define-syntax-rules, first not in > R6RS, > > so not portable ,does not exist in Kawa: > > #|kawa:1|# define-syntax-rules > > /dev/tty:1:1: warning - no declaration seen for define-syntax-rules > > /dev/tty:1:1: unbound location: define-syntax-rules > > > OK, make that > > (define-syntax ← > (syntax-rules () > ((← . args) > (<- . args)))) > > define-syntax-rule is merely a shortcut for syntax-rules > macros with just one rule like this (but it's indeed no > standard). > > > > but i test it with my guile code,fails too at run-time: > > scheme@(guile-user)> (logic-test) > > test 1 > > (or (and (not a) (not b) (not c) (not d)) (and (not a) (not b) (not c) d) > > (and > > (not a) (not b) c (not d)) (and (not a) b (not c) d) (and (not a) b c > (not > > d)) > > (and (not a) b c d) (and a (not b) (not c) (not d)) (and a (not b) (not > c) > > d) > > (and a (not b) c (not d)) (and c (not d))) = ice-9/boot-9.scm:1685:16: In > > procedure raise-exception: > > Unbound variable: lin > > > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > > scheme@(guile-user) [1]> ,bt > > In /Users/mattei/library-FunctProg/guile/logiki+.scm: > > 2848:18 5 (_ #<continuation 101c6a500>) > > 743:23 4 (infix-symb-min-dnf _) > > 1777:41 3 (minimal-dnf _) > > 2707:38 2 (_ _) > > 2526:19 1 (identify-essential-prime-implicants _ _) > > In ice-9/boot-9.scm: > > 1685:16 0 (raise-exception _ #:continuable? _) > > > > the offending code is here: > > > > ;; construction of the array > > ;; set the left column containing prime implicants > > (for-basic (lin 0 {lgt-pi - 1}) > > ;;(display "lin=") (display lin) (newline) > > ;;(display "{vct-prime-implicants[lin]}=") (display > > {vct-prime-implicants[lin]}) (newline) > > ;;(display "{iepi[{lin + 1} 0]}=") (display {iepi[{lin + 1} 0]}) > > (newline) > > {iepi[{lin + 1} 0] ← vct-prime-implicants[lin]}) > > ;;{iepi[{lin + 1} 0] <- vct-prime-implicants[lin]}) > > > > ;(display "iepi after") (newline) > > > > exactly here, just in the macro: > > {iepi[{lin + 1} 0] ← vct-prime-implicants[lin]}) > > in the macro lin is not more binded, so i suppose there is a problem of > > hygiene, the macro wipe out the binding of lin > > > > but it works at REPL,strange ... : > > > > 1685:16 0 (raise-exception _ #:continuable? _) > > scheme@(guile-user) [1]> ,q > > scheme@(guile-user)> {v <+ (vector 1 2 3 4)} > > scheme@(guile-user)> {v[1 : 3] <- #(-1 -2 -3 -4 -5 -6 -7)[2 : 4]} > > <- : #'(index ...) = (#<syntax:unknown file:6:3 1> #<syntax:unknown > file:6:5 > > :> #<syntax:unknown file:6:7 3>) > > <- : (syntax->datum #'(index ...)) = (1 : 3) > > <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> 1 : 3)> > > <- : (syntax->datum #'parsed-args)=(list 1 : 3) > > $bracket-apply$ : parsed-args=#<syntax > > (#<syntax:apply-square-brackets.scm:107:57 list> 2 : 4)> > > scheme@(guile-user)> v > > $1 = #(1 -3 -4 4) > > scheme@(guile-user)> {v[1 : 3] ← #(-1 -2 -3 -4 -5 -6 -7)[2 : 4]} > > <- : #'(index ...) = (#<syntax:unknown file:8:3 1> #<syntax:unknown > file:8:5 > > :> #<syntax:unknown file:8:7 3>) > > <- : (syntax->datum #'(index ...)) = (1 : 3) > > <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> 1 : 3)> > > <- : (syntax->datum #'parsed-args)=(list 1 : 3) > > $bracket-apply$ : parsed-args=#<syntax > > (#<syntax:apply-square-brackets.scm:107:57 list> 2 : 4)> > > scheme@(guile-user)> v > > $2 = #(1 -3 -4 4) > > scheme@(guile-user)> (define lin 1) > > scheme@(guile-user)> {v[lin : 3] ← #(-1 -2 -3 -4 -5 -6 -7)[2 : 4]} > > <- : #'(index ...) = (#<syntax:unknown file:11:3 lin> #<syntax:unknown > > file:11:7 :> #<syntax:unknown file:11:9 3>) > > <- : (syntax->datum #'(index ...)) = (lin : 3) > > <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> lin : > 3)> > > <- : (syntax->datum #'parsed-args)=(list lin : 3) > > $bracket-apply$ : parsed-args=#<syntax > > (#<syntax:apply-square-brackets.scm:107:57 list> 2 : 4)> > > scheme@(guile-user)> v > > $3 = #(1 -3 -4 4) > > > > and even with a variable ,i defined lin in the example > > > Hard to tell with so much code and without context on what > you're trying to do, but this might be caused precisely by > stripping identifier annotations. Consider: > > (define-syntax mac > (lambda (sintax) > (syntax-case sintax () > ((mac arg) > (datum->syntax #f (syntax->datum #'arg)))))) > > ;; Works: > ;; (define lin 6) > ;; (display (mac lin)) > > ;; Fails (as expected): > (let ((lin 5)) > (display (mac lin))) > > > yes frightening... the variable just disappeared... note in Racket the 2 examples fails: Welcome to DrRacket, version 8.12 [cs]. Language: racket, with debugging; memory limit: 8192 MB. > (define lin 6) > (display (mac lin)) lin: unbound identifier; also, no #%top syntax transformer is bound in: lin > (let ((lin 5)) (display (mac lin))) lin: unbound identifier; also, no #%top syntax transformer is bound in: lin > in Guile the 2 examples works: scheme@(guile-user)> (define-syntax mac (lambda (sintax) (syntax-case sintax () ((mac arg) (datum->syntax #f (syntax->datum #'arg)))))) scheme@(guile-user)> (define lin 6) scheme@(guile-user)> (display (mac lin)) 6scheme@(guile-user)> (let ((lin 5)) (display (mac lin))) 6scheme@(guile-user)> about my code , as i said it earlier, if i remove the datum->syntax #f (syntax->datum from my <- macro then your solution for ← works prefectly in the logic code but it then fails in the backpropagation deep learning code where + is overloaded with GOOPS so as i want the most compatible system i can not use it.But of course that would be better to understand what really happens. I'm not sure my code is well written but i can not clone this macro this way. About my code , i use a parser in command line and a macro system to extend the syntax of scheme, with macro doing the job in guile of parser in pre-compil time this is better because transparent for a guile coder that want to use scheme+. It is important to have pre-compil parsing of infix expression because the infix to prefix parsing is done one time before run time as it does not change after at runtime it is something that can be done before.(unless that the parsing is done at run time and if the calulus is in a loop this could be a big penalty about time) ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-10 13:52 ` Damien Mattei @ 2024-05-10 15:24 ` Jean Abou Samra 2024-05-10 20:21 ` Damien Mattei 2024-05-10 21:57 ` Damien Mattei 0 siblings, 2 replies; 25+ messages in thread From: Jean Abou Samra @ 2024-05-10 15:24 UTC (permalink / raw) To: Damien Mattei; +Cc: Maxime Devos, guile-user [-- Attachment #1: Type: text/plain, Size: 3882 bytes --] > but there should be something different with my macro and code because if i > put: > > (define-syntax ← > (syntax-rules () > ((← . args) > (<- . args)))) > > in my code i get again the warnings at compilation: > > ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:2526:19: warning: > possibly unbound variable `lin' > ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:2546:18: warning: > possibly unbound variable `col' > ;;; /Users/mattei/library-FunctProg/guile/logiki+.scm:2554:13: warning: > possibly unbound variable `lin-pos-epi' > > and the error at runtime: > scheme@(guile-user)> (logic-test) > test 1 > (or (and (not a) (not b) (not c) (not d)) (and (not a) (not b) (not c) d) (and > (not a) (not b) c (not d)) (and (not a) b (not c) d) (and (not a) b c (not d)) > (and (not a) b c d) (and a (not b) (not c) (not d)) (and a (not b) (not c) d) > (and a (not b) c (not d)) (and c (not d))) = ice-9/boot-9.scm:1685:16: In > procedure raise-exception: > Unbound variable: lin > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > scheme@(guile-user) [1]> > > so strictly talking it is not the same thing as calling ← defined like this: > > (define-syntax ← > (syntax-rules () > ((← . args) > (<- . args)))) > > and not the same as calling ← defined like this: > […] > even if the version above of ← is the same as <- ,i just replaced at any place > <- by ← > > i have no explains. I suppose there is something hard too understand with the > macro syntax system. I'd need a reproducible example to debug this. I have no explanation other than that there must be a trivial mistake somewhere in your code or testing procedure (happens to everyone). > i even tried this : > > (define-syntax ← > (syntax-rules () > ((_ ( ) expr) (<- ( ) expr)) > ((_ (var) expr) (<- (var) expr)) > ((_ (brket-applynext container index ...) expr) (<- (brket-applynext > container index ...) expr)) > ((_ var expr) (<- var expr)) > ((_ var var1 ... expr) (<- var var1 ... expr)))) > > to better respect the pattern of <- it fails too when call from ← Believe me, this is a red herring. > yes frightening... the variable just disappeared... I wouldn't call it frightening. It's completely expected, and documented. The hygiene algorithm is not that simple, but the intuitive high-level view of what happens here is that during the expansion of (let ((lin 5)) (display (mac lin))) the built-in let macro creates a kind of "access token" for the variable lin, and marks the body (display (mac lin)) with that token so that it has the variable lin in scope. This is so that forms introduced by macros (like mac here) which happen to also use the name lin will not interfere. Now, when you do the syntax->datum, you strip away all that information, and with (datum->syntax #f …), you convert the symbols back to syntax, but with zero scope information (as documented in the Guile manual). That means they can only refer to top-level variables. So the lookup of the local variable lin fails, but it works if lin is a global variable (because global variables are dynamic in Scheme, cf. module-set! and all that, unlike local variables which are static). > in Guile the 2 examples works: > > scheme@(guile-user)> (define-syntax mac > (lambda (sintax) > (syntax-case sintax () > ((mac arg) > (datum->syntax #f (syntax->datum #'arg)))))) > scheme@(guile-user)> (define lin 6) > scheme@(guile-user)> (display (mac lin)) > 6scheme@(guile-user)> (let ((lin 5)) > (display (mac lin))) > 6scheme@(guile-user)> Well, here, the second example runs but display 6, not 5, i.e. it looks up the global variable defined earlier, not the local one. [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-10 15:24 ` Jean Abou Samra @ 2024-05-10 20:21 ` Damien Mattei 2024-05-11 10:53 ` Damien Mattei 2024-05-10 21:57 ` Damien Mattei 1 sibling, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-10 20:21 UTC (permalink / raw) To: Jean Abou Samra; +Cc: Maxime Devos, guile-user On Fri, May 10, 2024 at 5:24 PM Jean Abou Samra <jean@abou-samra.fr> wrote: > > I'd need a reproducible example to debug this. I have no explanation > other than that there must be a trivial mistake somewhere in your > code or testing procedure (happens to everyone). > > i will try to isolate the problem out of 10000 lines of code but not sure to succeed there is no caveit in the testing procedure , i just have to comment/uncomment your procedure and mine, so no possible error in this procedure a mistake in my code would not change the fact that this code is a counter example to the cloning of a macro, the way you clone the macro should work for any macro that at least compile well. There is no error in the compilation of the macros. > > Well, here, the second example runs but display 6, not 5, i.e. it looks > up the global variable defined earlier, not the local one. > yes i did not noticed it ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-10 20:21 ` Damien Mattei @ 2024-05-11 10:53 ` Damien Mattei 2024-05-11 19:14 ` Jean Abou Samra 0 siblings, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-11 10:53 UTC (permalink / raw) To: Jean Abou Samra; +Cc: Maxime Devos, guile-user i understand the problem i have now in this new version, it is in the features of SRFI 105 : $brackett-apply$ $nfx$ and more that deals with [ ] , infix where i need to parse for operator precedence i have procedure for that: optimizer-parse-square-brackets-arguments-lister it takes a list in infix ,more complex than infix because it is compatible with the sliced format in Python (you know start : stop : step ,start ,step ,stop being infix expressions...) the problem when pre-compiling/pre-computing those lists is that with #' ,i mean syntax, the optimizer-parse-square-brackets-arguments-lister no more receive lists but this sort of expression: scheme@(guile-user)> (define T (make-vector 7)) scheme@(guile-user)> {T[2 + 1] <- 7} <- : #'(index ...) = (#<syntax:unknown file:3:3 2> #<syntax:unknown file:3:5 +> #<syntax:unknown file:3:7 1>) <- : (syntax->datum #'(index ...)) = (2 + 1) optimizer-parse-square-brackets-arguments-lister : args-brackets=(#<syntax:unknown file:3:3 2> #<syntax:unknown file:3:5 +> #<syntax:unknown file:3:7 1>) this expression is send to optimizer-parse-square-brackets-arguments-lister: (#<syntax:unknown file:3:3 2> #<syntax:unknown file:3:5 +> #<syntax:unknown file:3:7 1>) because i removed the (syntax->datum #'(index ...)) and simply give: #'(index ...) index ... are from the macro pattern: ((_ (brket-applynext container index ...) expr) my question is how to deal with that? becaue in the parser i check ,for example for + being '+ not some sort of #<syntax:unknown file:3:5 +> i suppose the problem come from here should i modify the parser to check for #'+ #'- #'* #'/ #'expt #'and #'or etc... or is there something to do when i pass arguments in the macro? also i pass #'(index ...) creating a sort of ( ) list ,how to pass th index and ellipsis in a syntax form ?? should i put that in a list with list procedure? my parser used to be like this and worked with operators ,it is in multiple file ,hard to display here: (define (optimizer-parse-square-brackets-arguments-lister args-brackets) (display "optimizer-parse-square-brackets-arguments-lister : args-brackets=") (display args-brackets) (newline) (optimizer-parse-square-brackets-arguments args-brackets (lambda (op a b) (list op a b)) infix-operators-lst-for-parser)) sintax below is a bit scheme+ (use return...) but can easily understand , i could have written it in tail recursive scheme also: ;; !*prec is defined in optimize-infix.scm ;; split the expression using slice as separator (def (optimizer-parse-square-brackets-arguments args-brackets creator operator-precedence) ;;(display "optimizer-parse-square-brackets-arguments : args-brackets=") (display args-brackets) (newline) (define operators-lst (apply append operator-precedence)) (when (null? args-brackets) (return args-brackets)) (declare result partial-result) (def (psba args) ;; parse square brackets arguments ,note: it is a tail-recursive function (see end) ;;(display "psba : args=") (display args) (newline) ;;(display "psba : partial-result =") (display partial-result) (newline) (when (null? args) ;;(display "before !*prec") (newline) (if (infix? partial-result operators-lst) (set! result (append result (!*prec-generic partial-result operator-precedence creator))) ;; !*prec-generic is defined in optimize-infix.scm (set! result (append result partial-result))) ;; (display "after !*prec") (newline) ;; (display result) (newline) ;; (display "return-rec") (newline) (return-rec result)) ;; return from all recursive calls, as it is tail recursive (define fst (car args)) ;;(display "fst=") (display fst) (newline) (if (equal? slice fst) ; separator ($> ;;(display "slice detected") (newline) ;;(display "psba : partial-result =") (display partial-result) (newline) (when (not (null? partial-result)) ;;(display "not null") (newline) (if (infix? partial-result operators-lst) ;; TODO infix? plante a cause des operateurs quotés (begin ;;(display "infix detected") (newline) (set! result (append result (!*prec-generic partial-result operator-precedence creator)))) ;; convert to prefix and store the expression (set! result (append result partial-result))) (set! partial-result '())) ;; empty for the next possible portion between slice operator (set! result (append result (list fst)))) ;; append the slice operator (set! partial-result (append partial-result (list fst)))) ;; not a slice operator but append it ;;(display "psba : result=") (display result) (newline) ;;(display "psba 2 : partial-result=") (display partial-result) (newline) (psba (cdr args))) ;; end def, recurse (tail recursive) ;;(display "parse-square-brackets-arguments : args-brackets=") (display args-brackets) (newline) (define rs (psba args-brackets)) ;;(display "parse-square-brackets-arguments : rs=") (display rs) (newline) rs ) ;; initial call (define infix-operators-lst-for-parser '( (expt **) (* / %) (+ -) (<< >>) (& ∣) (< > = ≠ <= >= <>) (and) (or) ;;(list 'dummy) ;; can keep the good order in case of non left-right assocciative operators.(odd? reverse them) (<- -> ← → := <v v> ⇜ ⇝) (<+ +> ⥆ ⥅ :+) ) ) ;; liste à plate des operateurs (define operators-lst (apply append infix-operators-lst-for-parser)) there is too much code i can not put it here... n-arity infix? too long... it. is just to give an idea, i hope problem can be solved in the macro call to optimizer-parse-square-brackets-arguments-lister On Fri, May 10, 2024 at 10:21 PM Damien Mattei <damien.mattei@gmail.com> wrote: > > > On Fri, May 10, 2024 at 5:24 PM Jean Abou Samra <jean@abou-samra.fr> > wrote: > >> >> I'd need a reproducible example to debug this. I have no explanation >> other than that there must be a trivial mistake somewhere in your >> code or testing procedure (happens to everyone). >> >> > i will try to isolate the problem out of 10000 lines of code but not sure > to succeed > there is no caveit in the testing procedure , i just have to > comment/uncomment your procedure and mine, so no possible error in this > procedure > > a mistake in my code would not change the fact that this code is a counter > example to the cloning of a macro, the way you clone the macro should work > for any macro that at least compile well. There is no error in the > compilation of the macros. > >> >> Well, here, the second example runs but display 6, not 5, i.e. it looks >> up the global variable defined earlier, not the local one. >> > yes i did not noticed it > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-11 10:53 ` Damien Mattei @ 2024-05-11 19:14 ` Jean Abou Samra 2024-05-12 12:37 ` Damien Mattei 0 siblings, 1 reply; 25+ messages in thread From: Jean Abou Samra @ 2024-05-11 19:14 UTC (permalink / raw) To: Damien Mattei; +Cc: Maxime Devos, guile-user [-- Attachment #1: Type: text/plain, Size: 1636 bytes --] > the problem when pre-compiling/pre-computing those lists is that with #' , > i mean syntax, the optimizer-parse-square-brackets-arguments-lister no > more receive lists but this sort of expression: > > scheme@(guile-user)> (define T (make-vector 7)) > scheme@(guile-user)> {T[2 + 1] <- 7} > <- : #'(index ...) = (#<syntax:unknown file:3:3 2> #<syntax:unknown file:3:5 +> #<syntax:unknown file:3:7 1>) > <- : (syntax->datum #'(index ...)) = (2 + 1) > optimizer-parse-square-brackets-arguments-lister : args-brackets=(#<syntax:unknown file:3:3 2> #<syntax:unknown file:3:5 +> #<syntax:unknown file:3:7 1>) Yes, these are wrapped syntax objects. > my question is how to deal with that? There are a variety of tools to work with syntax objects, just like there are tools to work with lists. Among them: syntax (#'), quasisyntax (#`), unsyntax (#,), unsyntax-splicing (#,@), identifier?, free-identifier=?, bound-identifier=?, and of course syntax-case. > becaue in the parser i check ,for example for + being '+ not some sort of #<syntax:unknown file:3:5 +> > i suppose the problem come from here > should i modify the parser to check for #'+ #'- #'* #'/ #'expt #'and #'or etc... or is there something to do when i pass arguments in the macro? Use (free-identifier=? the-identifier #'+) > also i pass #'(index ...) creating a sort of ( ) list ,how to pass th index and ellipsis in a syntax form ?? should i put that in a list with list procedure? #'(index ...) is a traditional list (not a wrapped syntax object), so you can work with it directly (its elements are wrapped syntax objects). [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-11 19:14 ` Jean Abou Samra @ 2024-05-12 12:37 ` Damien Mattei 0 siblings, 0 replies; 25+ messages in thread From: Damien Mattei @ 2024-05-12 12:37 UTC (permalink / raw) To: Jean Abou Samra; +Cc: Maxime Devos, guile-user thank you, i think now i understand better the macro syntax system of R6RS, i will use all that to have in the next version of Scheme+ two systems: -still the command line parser that parse for example infix (and slicing) with operator precedence to prefix -a transparent system for the user that will use macro to pre-parse the code (no need to parse it in command line) on the fly (like the command line parser do it) at the pre-compil stage of the macro,then use the pre-parsed code in the expansion phase. Finally the run-time execution of the generated code will be faster as no parsing will be done at this run-time phase.All that being compatible with the syntax of Guile using curli-infix SRFI 105. Just a lot of code to refactor to use both symbolic expression (sexpr) in the parser mode and now syntactic expression with the macros (modify $brackett-apply$ $nfx$ etc ... and the procedure called by those). With syntax it is more easy to manipulate special form like 'and' / 'or' that cannot be manipulate like procedures * + - / unless quoted which is not a good thing because when quoted the re-evaluation always cause problems.(different environment when eval) The use of syntax avoid this problem.(which does not exist indeed in the command line parser as i only parse symbolic code) Using R6RS syntax the hygiene too should be better. On Sat, May 11, 2024 at 9:14 PM Jean Abou Samra <jean@abou-samra.fr> wrote: > > the problem when pre-compiling/pre-computing those lists is that with #' > , > > i mean syntax, the optimizer-parse-square-brackets-arguments-lister no > > more receive lists but this sort of expression: > > > > scheme@(guile-user)> (define T (make-vector 7)) > > scheme@(guile-user)> {T[2 + 1] <- 7} > > <- : #'(index ...) = (#<syntax:unknown file:3:3 2> #<syntax:unknown > file:3:5 +> #<syntax:unknown file:3:7 1>) > > <- : (syntax->datum #'(index ...)) = (2 + 1) > > optimizer-parse-square-brackets-arguments-lister : > args-brackets=(#<syntax:unknown file:3:3 2> #<syntax:unknown file:3:5 +> > #<syntax:unknown file:3:7 1>) > > Yes, these are wrapped syntax objects. > > > my question is how to deal with that? > > There are a variety of tools to work with syntax objects, just like > there are tools to work with lists. Among them: syntax (#'), > quasisyntax (#`), unsyntax (#,), unsyntax-splicing (#,@), > identifier?, free-identifier=?, bound-identifier=?, and of > course syntax-case. > > > becaue in the parser i check ,for example for + being '+ not some sort > of #<syntax:unknown file:3:5 +> > > i suppose the problem come from here > > should i modify the parser to check for #'+ #'- #'* #'/ #'expt #'and > #'or etc... or is there something to do when i pass arguments in the macro? > > Use (free-identifier=? the-identifier #'+) > > > also i pass #'(index ...) creating a sort of ( ) list ,how to pass th > index and ellipsis in a syntax form ?? should i put that in a list with > list procedure? > > #'(index ...) is a traditional list (not a wrapped syntax object), so you > can work with it directly (its elements are wrapped syntax objects). > > > > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-10 15:24 ` Jean Abou Samra 2024-05-10 20:21 ` Damien Mattei @ 2024-05-10 21:57 ` Damien Mattei 2024-05-10 22:23 ` Jean Abou Samra 1 sibling, 1 reply; 25+ messages in thread From: Damien Mattei @ 2024-05-10 21:57 UTC (permalink / raw) To: Jean Abou Samra; +Cc: Maxime Devos, guile-user On Fri, May 10, 2024 at 5:24 PM Jean Abou Samra <jean@abou-samra.fr> wrote: > > the built-in let macro creates a kind of "access token" for the variable > lin, and marks the body (display (mac lin)) with that token so that it > has the variable lin in scope. This is so that forms introduced by macros > (like mac here) which happen to also use the name lin will not interfere. > Now, when you do the syntax->datum, you strip away all that information, > and with (datum->syntax #f …), you convert the symbols back to syntax, > but with zero scope information (as documented in the Guile manual). > That means they can only refer to top-level variables. So the lookup > of the local variable lin fails, but it works if lin is a global variable > (because global variables are dynamic in Scheme, cf. module-set! and all > that, unlike local variables which are static). > > > > in Guile the 2 examples works: > > > > scheme@(guile-user)> (define-syntax mac > > (lambda (sintax) > > (syntax-case sintax () > > ((mac arg) > > (datum->syntax #f (syntax->datum #'arg)))))) > > scheme@(guile-user)> (define lin 6) > > scheme@(guile-user)> (display (mac lin)) > > 6scheme@(guile-user)> (let ((lin 5)) > > (display (mac lin))) > > 6scheme@(guile-user)> > > > Well, here, the second example runs but display 6, not 5, i.e. it looks > up the global variable defined earlier, not the local one. > > > yes with a global variables the things are different , my macro too find the global variable here is the simplest counter example i can create,not in a program just at REPL with this version of Scheme+: i will use 2 simple example: (let ((lin 2)) {T[lin 1] <- -5}) and (let ((lin 2)) {T[lin 1] ← -5}) the first works ,not the second GNU Guile 3.0.8.99-f3ea8 scheme@(guile-user)>(use-modules (Scheme+)) scheme@(guile-user)> (use-modules (array)) scheme@(guile-user)> (define T (make-array-2d 5 3 0)) scheme@(guile-user)> T $1 = #(#(0 0 0) #(0 0 0) #(0 0 0) #(0 0 0) #(0 0 0)) scheme@(guile-user)> (let ((lin 2)) {T[lin 1] <- -5}) <- : #'(index ...) = (#<syntax:unknown file:6:18 lin> #<syntax:unknown file:6:23 1>) <- : (syntax->datum #'(index ...)) = (lin 1) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> lin 1)> <- : (syntax->datum #'parsed-args)=(list lin 1) scheme@(guile-user)> T $1 = #(#(0 0 0) #(0 0 0) #(0 -5 0) #(0 0 0) #(0 0 0)) scheme@(guile-user)> (define T (make-array-2d 5 3 0)) scheme@(guile-user)> T $2 = #(#(0 0 0) #(0 0 0) #(0 0 0) #(0 0 0) #(0 0 0)) scheme@(guile-user)> (let ((lin 2)) {T[lin 1] ← -5}) <- : #'(index ...) = (#<syntax:unknown file:10:18 lin> #<syntax:unknown file:10:23 1>) <- : (syntax->datum #'(index ...)) = (lin 1) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> lin 1)> <- : (syntax->datum #'parsed-args)=(list lin 1) ;;; <stdin>:10:15: warning: possibly unbound variable `lin' ice-9/boot-9.scm:1685:16: In procedure raise-exception: Unbound variable: lin Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user) [1]> ,bt In current input: 10:15 1 (_) In ice-9/boot-9.scm: 1685:16 0 (raise-exception _ #:continuable? _) here is a longer example, more near the logiki code and things are worst: (define (foo) {T ← (make-array-2d 5 3 0)} (for-basic (lin 0 4) (display lin) (newline) {T[lin 1] ← -5}) T) foo should create T a 2D array : #(#(0 0 0) #(0 0 0) #(0 0 0) #(0 0 0) #(0 0 0)) the for loop from 0 to 4 display lin ,set T[lin 1] to -5 and return T but it fails and the compiler warn me about lin undefined (if i define lin at top level it compile but the code will not use lin of the loop but of top level and it acts as if there is 2 lin variables! the one of toplevel that is used in {T[lin 1] ← -5} and the one of the loop for-basic that is used in (display lin) (newline) ! : scheme@(guile-user)> (define lin 1) scheme@(guile-user)> (define (foo) {T ← (make-array-2d 5 3 0)} (for-basic (lin 0 4) (display lin) (newline) {T[lin 1] ← -5}) T) <- : #'(index ...) = (#<syntax:unknown file:40:29 lin> #<syntax:unknown file:40:33 1>) <- : (syntax->datum #'(index ...)) = (lin 1) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> lin 1)> <- : (syntax->datum #'parsed-args)=(list lin 1) scheme@(guile-user)> (foo) 0 1 2 3 4 $11 = #(#(0 0 0) #(0 -5 0) #(0 0 0) #(0 0 0) #(0 0 0)) notice only one element of array as been modified if i use <- directly it works: scheme@(guile-user)> (define (bar) {T <- (make-array-2d 5 3 0)} (for-basic (lin 0 4) (display lin)(newline) {T[lin 1] <- -5}) T) <- : #'(index ...) = (#<syntax:unknown file:31:90 lin> #<syntax:unknown file:31:95 1>) <- : (syntax->datum #'(index ...)) = (lin 1) <- : #'parsed-args=#<syntax (#<syntax:assignment.scm:116:64 list> lin 1)> <- : (syntax->datum #'parsed-args)=(list lin 1) scheme@ of course all this is made by the datum->syntax in this part of the macro: ;; parse arguments at posteriori here: (with-syntax ((parsed-args (datum->syntax stx ; #f (cons #'list (optimizer-parse-square-brackets-arguments-lister (syntax->datum #'(index ...))))))) to run those example i did not even need to comment/uncomment code or recompile logiki, i just used the toplevel with scheme+ but in this version i use the cloning with: (define-syntax ← (syntax-rules () ((← . args) (<- . args)))) it is clear that calling <- via ← give a bad result, if instead i use directly <- code works. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-10 21:57 ` Damien Mattei @ 2024-05-10 22:23 ` Jean Abou Samra 2024-05-10 23:04 ` Damien Mattei 0 siblings, 1 reply; 25+ messages in thread From: Jean Abou Samra @ 2024-05-10 22:23 UTC (permalink / raw) To: Damien Mattei; +Cc: Maxime Devos, guile-user [-- Attachment #1: Type: text/plain, Size: 1158 bytes --] > it is clear that calling <- via ← give a bad result, if instead i use directly > <- code works. OK, I think I get it now: (define-syntax <- (lambda (sintax) (syntax-case sintax () ((<- arg) (datum->syntax sintax (syntax->datum #'arg)))))) ;; Works: (let ((foo "ABCD\n")) (display (<- foo))) (define-syntax-rule (← . args) (<- . args)) ;; Fails (as expected, documented and standard): (let ((foo "ABCD\n")) (display (← foo))) Well, I was wrong that you had to go out of your way to make a difference between <- and ←. In fact it's a lot simpler than I thought, as the example above shows. But Maxime and I told you that this syntax->datum → process → datum->syntax dance was not a good idea. Now you've learnt why, the hard way :-) In the datum->syntax call, if you use the macro's argument (which I called "sintax"), the lexical context introduced is wherever the macro was expanded. In the case of ←, that's in the body of the macro definition of ←, so variables from the let form where foo is bound are unavailable. Don't make your life complicated for no reason :-) [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: with-syntax return error in Guile, not in Kawa or Racket 2024-05-10 22:23 ` Jean Abou Samra @ 2024-05-10 23:04 ` Damien Mattei 0 siblings, 0 replies; 25+ messages in thread From: Damien Mattei @ 2024-05-10 23:04 UTC (permalink / raw) To: Jean Abou Samra; +Cc: Maxime Devos, guile-user On Sat, May 11, 2024 at 12:23 AM Jean Abou Samra <jean@abou-samra.fr> wrote: > > it is clear that calling <- via ← give a bad result, if instead i use > directly > > <- code works. > > OK, I think I get it now: > > (define-syntax <- > (lambda (sintax) > (syntax-case sintax () > ((<- arg) > (datum->syntax sintax (syntax->datum #'arg)))))) > > ;; Works: > (let ((foo "ABCD\n")) > (display (<- foo))) > > (define-syntax-rule (← . args) (<- . args)) > > ;; Fails (as expected, documented and standard): > (let ((foo "ABCD\n")) > (display (← foo))) > > > > Well, I was wrong that you had to go out of your way to make > a difference between <- and ←. thank you :-) In fact it's a lot simpler than > I thought, as the example above shows. But Maxime and I told > you that this syntax->datum → process → datum->syntax dance > was not a good idea. Now you've learnt why, the hard way :-) > > yes :-) it is a good lesson as we say in France > In the datum->syntax call, if you use the macro's argument > (which I called "sintax"), the lexical context introduced > is wherever the macro was expanded. In the case of ←, > that's in the body of the macro definition of ←, so variables > from the let form where foo is bound are unavailable. > yes again i undestood at least this ,if #f is used there is an empty lexical context, if it is the stx of the macro then it is the lexical context is the one where the macro is expanded (but not runtime?) the lexical context is local , i understand a bit more... > > Don't make your life complicated for no reason :-) > but it is not for no reason :-) : i had now one code (logiki) that works when i remove the "syntax->datum → process → datum->syntax" just keep process with the cloned ← macro OR do not clone the macro ← (2 solutions) and copy it entirely In this case the best solution is to get rid of "syntax->datum → process → datum->syntax" just keep process and the simple cloned macro but i have another code : back-propagation which no more works if i get rid of "syntax->datum → process → datum->syntax" so tomorrow i will dig in the back-propagation code to see why it no more works without "syntax->datum → process → datum->syntax" i had patched this solution without well understanding what happens but tomorrow i do not want to make another 5.00 AM clock sleeping.... that's not good for the brain ;-) ^ permalink raw reply [flat|nested] 25+ messages in thread
* Macros that don't work 2024-05-09 22:35 ` Jean Abou Samra 2024-05-10 9:40 ` Damien Mattei @ 2024-05-15 17:44 ` Keith Wright 1 sibling, 0 replies; 25+ messages in thread From: Keith Wright @ 2024-05-15 17:44 UTC (permalink / raw) To: guile-user You are doing great work that I do not understand. Though I worry that by the time we have worked on it long enough to know how it should be done, we are too tired to do it, Still, I am happy to still be living, learning, and understanding more. I am deterimined to understand how macros should work. I think I could learn by entering a macro (@REPL) and seeing (not evaluating) the expanded result. Is this possible with Guile? Your Student, -- Keith --- PS: I don't want to utter a seldom heard discouraging word, but I do want to be a chearleader for fixing the damned thing. > From: Andy Wingo <wingo@pobox.com> > Subject: GNU Guile 3.0.8 released > Date: Fri, 11 Feb 2022 08:47:48 +0100 > > Note however that as with macros, when a definition changes in module A, > a separately compiled module B that uses that definition doesn't > automatically get recompiled. This is a limitation in Guile that we > would like to fix. I would call it a high priority bug. Can it be disabled by default? If you can't auto-compile what needs to be compiled, then don't auto-compile at all. > From: Jean Abou Samra <jean@abou-samra.fr> > Subject: Re: with-syntax return error in Guile, not in Kawa or Racket > Date: Fri, 10 May 2024 00:35:32 +0200 > > Maybe you have several files and you forgot to clear the bytecode cache? I can say with confidence that I have never forgotten that, since I never learned it in the first place. Is it in the manual? Do I have to do it by hand? When? Is there a compiler option to do it always? If so, it should be the default. > Jean> Keep in mind that Guile doesn't do dependency tracking: if file > B uses a macro defined in file A and file A changes, B won't be > recompiled automatically, and will use the expansions from the old > macros until you clear the cache or use --no-auto-compile or similar. If you must re-make make, make it right. ^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2024-05-15 17:44 UTC | newest] Thread overview: 25+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-05-05 12:36 with-syntax return error in Guile, not in Kawa or Racket Damien Mattei 2024-05-05 12:48 ` Jean Abou Samra 2024-05-05 13:35 ` Damien Mattei 2024-05-06 7:27 ` Damien Mattei 2024-05-06 9:41 ` Jean Abou Samra 2024-05-06 10:29 ` Damien Mattei 2024-05-06 12:03 ` Damien Mattei 2024-05-06 17:52 ` Damien Mattei 2024-05-06 18:58 ` Maxime Devos 2024-05-06 21:34 ` Damien Mattei 2024-05-09 9:21 ` Maxime Devos 2024-05-09 21:56 ` Damien Mattei 2024-05-09 22:35 ` Jean Abou Samra 2024-05-10 9:40 ` Damien Mattei 2024-05-10 10:33 ` Jean Abou Samra 2024-05-10 13:52 ` Damien Mattei 2024-05-10 15:24 ` Jean Abou Samra 2024-05-10 20:21 ` Damien Mattei 2024-05-11 10:53 ` Damien Mattei 2024-05-11 19:14 ` Jean Abou Samra 2024-05-12 12:37 ` Damien Mattei 2024-05-10 21:57 ` Damien Mattei 2024-05-10 22:23 ` Jean Abou Samra 2024-05-10 23:04 ` Damien Mattei 2024-05-15 17:44 ` Macros that don't work Keith Wright
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).