From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.user Subject: adding #' syntax and my cloned macro no more works like original.... Date: Thu, 9 May 2024 11:07:59 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10854"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu May 09 11:09:02 2024 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s4zlu-0002gY-DX for guile-user@m.gmane-mx.org; Thu, 09 May 2024 11:09:02 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4zlG-0004PD-OD; Thu, 09 May 2024 05:08:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s4zlA-0004OV-73 for guile-user@gnu.org; Thu, 09 May 2024 05:08:17 -0400 Original-Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4zl7-0002U4-Kp for guile-user@gnu.org; Thu, 09 May 2024 05:08:15 -0400 Original-Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-78f05341128so38318885a.0 for ; Thu, 09 May 2024 02:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715245691; x=1715850491; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=LQvMKUNUbe13QymRldAlC4wcPYoEuFcfv/Zn7upcfOQ=; b=JTHDx497KF+kRAmPldqOd193Pk8mg7dPkj2VXKA0DGmxsZ1NVq1owggBTbkFEg+few J8Wgs9X9RjXHbvOl3vaZQ2AAoEmStr/Vuj3G6pkbwXQR/OgcmicK+IyZVqbA8c4ZDFwd Dg2SiNg9eK+qkL1Z3bRaY7ClbrBz+rxUhLQEfliqPhEEJXfW9V6JTM9NkEj19Dn1Ktbh 33Dr7AdM1aBtS6c5ZNyWq0eceeotit9EwTMsC4sbLqzUvpMZPHaqQTsf09xgK3fD1TPU fgbCf2GHj3nrGxiIxqHxmiEoliFrcI1evrCMk4J/6iSfVqW3go8XVUbOZXsnFTgpxH/B 9DGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715245691; x=1715850491; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=LQvMKUNUbe13QymRldAlC4wcPYoEuFcfv/Zn7upcfOQ=; b=caVs1DlKU6Lf7BD9I5fP/aUZEGOjBJGe6pe2FPEtewtwo08HTYsOUA2wk7ZvdBdqa3 FhjlgBfzKtHVicUpi8vWanFtN3Dnii3rgcEHHD1nB/BvuGq9rLij5EvV7tvwYIsNQ2ne m/2sU+3QLEIpMipGzC6Gg9AcjuB2Wwr+o29oA35pUOzEpGycNLBu+IaGIgZtR3rWBhUF lx1yHbYPOu/eiRBJiYG03nQDlC5Q4nJkChtI9zgobXEC4v/iugLhNSTy4sU0RZVjEYpG UfmsWfsF1OdTo55abMUsCuUBVqPp7dtj/uqSRxRbwsGkkiJZURHdLk8lCvLzjoGXGpD0 vogQ== X-Gm-Message-State: AOJu0YxIoNZICSbLZZ3WkmognluTDSon9HoCS7Uf0WsZQGbKgWb3XLUX 6T+pLI62MOV1Gq1Nu3JTsrJcxGpeA6eqdYaOVwMnst1diu0p4HKASOMRyHR1z3IGs2l2LrT4U6K cTlzK3Ce/v/g4MnXZTDKbB8Y0IuBmd0jvQxc= X-Google-Smtp-Source: AGHT+IH+NZr3IjjqvXkIVXb8A2JgbjB67ExihXbbtXBrm1lVlZT/9SLMBb19RUbRHA+4EOE9lygszEzHmA9G71z0S9U= X-Received: by 2002:a05:6214:1d01:b0:6a0:8a49:b796 with SMTP id 6a1803df08f44-6a1514f07d5mr58600476d6.62.1715245691379; Thu, 09 May 2024 02:08:11 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::72b; envelope-from=damien.mattei@gmail.com; helo=mail-qk1-x72b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_FONT_LOW_CONTRAST=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19609 Archived-At: hello, i having a little horrific bug in one of my macro. In fact i have 2 macro : <- that do all the job and another alias =E2=86=90 till now the =E2=86=90 acted as a perfect clone of <- wihtout having all th= e code, being defined as: (define-syntax =E2=86=90 ;; under Linux this symbol can be typed with the ;; combination of keys: Ctrl-Shift-u 2190 where 2190 is the unicode of left arrow (syntax-rules () ((_ var ...) (<- var ...)))) but now that i added a few 'syntax' to <- , i have errors using =E2=86=90 ,= some bindings become unbinded: error is sort of : 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]> ,q appearing in: {iepi[{lin + 1} 0] =E2=86=90 vct-prime-implicants[lin]} if i replace it with: {iepi[{lin + 1} 0] <- vct-prime-implicants[lin]} all works again. backtrace is of no help, sort of: scheme@(guile-user) [1]> ,bt In /Users/mattei/library-FunctProg/guile/logiki+.scm: 2848:18 5 (_ #) 743:23 4 (infix-symb-min-dnf _) 1777:41 3 (minimal-dnf _) 2707:38 2 (_ _) 2546:18 1 (identify-essential-prime-implicants _ _) In ice-9/boot-9.scm: 1685:16 0 (raise-exception _ #:continuable? _) i know it is a macro problem, not in procedures,and it is since i added some #' syntax to optimize code... a solution would be to duplicate all the code from <- into =E2=86=90 but th= is is stupid. how can i change =E2=86=90 to act perfectly as <- ? i'm afraid to post it but i think i must post the code of <- to get any help about that: ;; {s <+ (string-append "abcdefgh")};; "abcdefgh";; > {s[2 * 3 - 4 $ 2 * 3 + 1 $ 2 * 4 - 6] <- "0000"};; "ab0d0f0h" ;; $bracket-apply$ is from SRFI 105 bracket-apply is an argument of the macro(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 "<- : (syntax->datum #'(index ...)) =3D ") (display (syntax->datum #'(index ...))) (newline) (display "<- : (number? (car (syntax->datum #'(index ...)))) =3D ") (display (number? (car (syntax->datum #'(index ...))))) (newline) =09 ;; parse arguments at posteriori here: (with-syntax ((parsed-args (datum->syntax stx ; #f (cons #'list (optimizer-parse-square-brackets-arguments-lister (syntax->datum #'(index ...))))))) (display "<- : #'parsed-args=3D") (display #'parsed-args) (newline) (display "<- : (syntax->datum #'parsed-args)=3D") (display (syntax->datum #'parsed-args)) (newline) =09 ;;(case (length (syntax->datum #'(index ...))) (case (length (cdr (syntax->datum #'parsed-args))) ;; 0 argument in [] ;; T[] ;; {v[] <- #(1 2 3)} ;; > v ;;'#(1 2 3) ((0) #'(assignment-argument-0 container expr)) ; possible to have NO i= ndex ;; 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 =09 (first parsed-args) (second parsed-args) (third parsed-args) expr)) =09 ;; 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))} ;; # ;; > {I[0 0] <- I[1 1] <- I[2 2] <- I[3 3] <- 1} ;; 1 ;; > {I[0 0]} ;; 1 ;; > {I[0 1]} ;; 0 ;; > I ;; # ;; > (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) =09 (define return-values-of-expr (create-return-values expr)) (<- var (return-values-of-expr)) ;;(display "<- : case : passed (<- var expr)") (newline) ;;(display "<- : case : var=3D") (display var) (newline) =09 (<- var1 (return-values-of-expr)) ...)) ))) Best regards, Damien