unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* write simpler a syntax form ?
@ 2024-05-15 23:00 Damien Mattei
  2024-05-16  5:51 ` Damien Mattei
  0 siblings, 1 reply; 4+ messages in thread
From: Damien Mattei @ 2024-05-15 23:00 UTC (permalink / raw)
  To: guile-user

do you think this can be written simpler?

#`(list #,@(optimizer-parse-square-brackets-arguments-lister-syntax
#`(#,@#'args-brackets)))

i'm quite afraid the look the 'syntax' get....

it is part of this macro:

(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]}
      ;; optimizer-parse-square-brackets-arguments-lister-syntax :
args-brackets=(#<syntax:unknown file:2:22 6> #<syntax:unknown
file:2:24 -> #<syntax:unknown file:2:26 4> #<syntax:unknown file:2:28
:> #<syntax:unknown file:2:30 5> #<syntax:unknown file:2:32 +>
#<syntax:unknown file:2:34 2>)
      ;; $bracket-apply$ :
#'parsed-args=(#<syntax:apply-square-brackets.scm:106:37 list>
(#<syntax:unknown file:2:24 -> #<syntax:unknown file:2:22 6>
#<syntax:unknown file:2:26 4>) #<syntax:unknown file:2:28 :>
(#<syntax:unknown file:2:32 +> #<syntax:unknown file:2:30 5>
#<syntax:unknown file:2:34 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]}
      ;; optimizer-parse-square-brackets-arguments-lister-syntax :
args-brackets=(#<syntax:unknown file:4:22 6> #<syntax:unknown
file:4:24 -> #<syntax:unknown file:4:26 4> #<syntax:unknown file:4:28
:> #<syntax:unknown file:4:30 i> #<syntax:unknown file:4:32 +>
#<syntax:unknown file:4:34 2>)
      ;; $bracket-apply$ :
#'parsed-args=(#<syntax:apply-square-brackets.scm:106:37 list>
(#<syntax:unknown file:4:24 -> #<syntax:unknown file:4:22 6>
#<syntax:unknown file:4:26 4>) #<syntax:unknown file:4:28 :>
(#<syntax:unknown file:4:32 +> #<syntax:unknown file:4:30 i>
#<syntax:unknown file:4:34 2>))
      ;; $2 = #(3 4 5 6 7)
      (($bracket-apply$ container . args-brackets)


       (with-syntax ((parsed-args #`(list
#,@(optimizer-parse-square-brackets-arguments-lister-syntax
#`(#,@#'args-brackets)))))
		
		    (display "$bracket-apply$ : #'parsed-args=") (display
#'parsed-args) (newline)
		
		    #'($bracket-apply$next4list-args container parsed-args))))))


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: write simpler a syntax form ?
  2024-05-15 23:00 write simpler a syntax form ? Damien Mattei
@ 2024-05-16  5:51 ` Damien Mattei
  2024-05-24 13:08   ` Jean Abou Samra
  0 siblings, 1 reply; 4+ messages in thread
From: Damien Mattei @ 2024-05-16  5:51 UTC (permalink / raw)
  To: guile-user

note that this simplification works:

(cons #'list
         (optimizer-parse-square-brackets-arguments-lister-syntax
#`(#,@#'args-brackets)))))

but all attempt to simplify this part: #`(#,@#'args-brackets)
gives errors


On Thu, May 16, 2024 at 1:00 AM Damien Mattei <damien.mattei@gmail.com>
wrote:

> do you think this can be written simpler?
>
> #`(list #,@(optimizer-parse-square-brackets-arguments-lister-syntax
> #`(#,@#'args-brackets)))
>
> i'm quite afraid the look the 'syntax' get....
>
> it is part of this macro:
>
> (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]}
>       ;; optimizer-parse-square-brackets-arguments-lister-syntax : args-brackets=(#<syntax:unknown file:2:22 6> #<syntax:unknown file:2:24 -> #<syntax:unknown file:2:26 4> #<syntax:unknown file:2:28 :> #<syntax:unknown file:2:30 5> #<syntax:unknown file:2:32 +> #<syntax:unknown file:2:34 2>)
>       ;; $bracket-apply$ : #'parsed-args=(#<syntax:apply-square-brackets.scm:106:37 list> (#<syntax:unknown file:2:24 -> #<syntax:unknown file:2:22 6> #<syntax:unknown file:2:26 4>) #<syntax:unknown file:2:28 :> (#<syntax:unknown file:2:32 +> #<syntax:unknown file:2:30 5> #<syntax:unknown file:2:34 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]}
>       ;; optimizer-parse-square-brackets-arguments-lister-syntax : args-brackets=(#<syntax:unknown file:4:22 6> #<syntax:unknown file:4:24 -> #<syntax:unknown file:4:26 4> #<syntax:unknown file:4:28 :> #<syntax:unknown file:4:30 i> #<syntax:unknown file:4:32 +> #<syntax:unknown file:4:34 2>)
>       ;; $bracket-apply$ : #'parsed-args=(#<syntax:apply-square-brackets.scm:106:37 list> (#<syntax:unknown file:4:24 -> #<syntax:unknown file:4:22 6> #<syntax:unknown file:4:26 4>) #<syntax:unknown file:4:28 :> (#<syntax:unknown file:4:32 +> #<syntax:unknown file:4:30 i> #<syntax:unknown file:4:34 2>))
>       ;; $2 = #(3 4 5 6 7)
>       (($bracket-apply$ container . args-brackets)
>
>
>        (with-syntax ((parsed-args #`(list #,@(optimizer-parse-square-brackets-arguments-lister-syntax #`(#,@#'args-brackets)))))	
> 		
> 		    (display "$bracket-apply$ : #'parsed-args=") (display #'parsed-args) (newline)
> 		
> 		    #'($bracket-apply$next4list-args container parsed-args))))))
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: write simpler a syntax form ?
  2024-05-16  5:51 ` Damien Mattei
@ 2024-05-24 13:08   ` Jean Abou Samra
  2024-05-25 14:12     ` Damien Mattei
  0 siblings, 1 reply; 4+ messages in thread
From: Jean Abou Samra @ 2024-05-24 13:08 UTC (permalink / raw)
  To: Damien Mattei, guile-user

[-- Attachment #1: Type: text/plain, Size: 275 bytes --]


> all attempt to simplify this part: #`(#,@#'args-brackets)
> gives errors



Try matching it with ($bracket-apply$ container args-brackets ...) instead of
($bracket-apply container . args-brackets) and replacing #`(#,@#'args-brackets)
with #'(args-brackets ...)


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: write simpler a syntax form ?
  2024-05-24 13:08   ` Jean Abou Samra
@ 2024-05-25 14:12     ` Damien Mattei
  0 siblings, 0 replies; 4+ messages in thread
From: Damien Mattei @ 2024-05-25 14:12 UTC (permalink / raw)
  To: Jean Abou Samra; +Cc: guile-user

yes it works.
thanks
i will use this version,it is simpler

On Fri, May 24, 2024 at 3:08 PM Jean Abou Samra <jean@abou-samra.fr> wrote:

>
> > all attempt to simplify this part: #`(#,@#'args-brackets)
> > gives errors
>
>
>
> Try matching it with ($bracket-apply$ container args-brackets ...) instead
> of
> ($bracket-apply container . args-brackets) and replacing
> #`(#,@#'args-brackets)
> with #'(args-brackets ...)
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-25 14:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-15 23:00 write simpler a syntax form ? Damien Mattei
2024-05-16  5:51 ` Damien Mattei
2024-05-24 13:08   ` Jean Abou Samra
2024-05-25 14:12     ` Damien Mattei

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).