From: Damien Mattei <damien.mattei@gmail.com>
To: Maxime Devos <maximedevos@telenet.be>
Cc: Jean Abou Samra <jean@abou-samra.fr>, guile-user <guile-user@gnu.org>
Subject: Re: with-syntax return error in Guile, not in Kawa or Racket
Date: Mon, 6 May 2024 23:34:53 +0200 [thread overview]
Message-ID: <CADEOadeq=VFY11w7g_=5QkBhGGdRQ-z=N2A2D4q8M-ApF157MA@mail.gmail.com> (raw)
In-Reply-To: <20240506205840.Kuyd2C00E17cfcj01uyfo5@xavier.telenet-ops.be>
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.
>
next prev parent reply other threads:[~2024-05-06 21:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADEOadeq=VFY11w7g_=5QkBhGGdRQ-z=N2A2D4q8M-ApF157MA@mail.gmail.com' \
--to=damien.mattei@gmail.com \
--cc=guile-user@gnu.org \
--cc=jean@abou-samra.fr \
--cc=maximedevos@telenet.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).