unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Jean Abou Samra <jean@abou-samra.fr>
To: guile-user@gnu.org
Subject: Syntax objects as traditional pairs
Date: Tue, 5 Apr 2022 01:00:04 +0200	[thread overview]
Message-ID: <1024dc44-d9f2-80b5-4b26-01a3779052ee@abou-samra.fr> (raw)

Hi,

I am lost as to when a syntax object whose syntax->datum is a pair
can be manipulated as a plain Scheme pair. For example:


(define synt1 #'(a b))
(pk 'syntax synt1 'pair? (pair? synt1))
(pk 'car (car synt1))

(define-syntax mysyntax
   (lambda (stax)
     (syntax-case stax ()
       ((_ thing)
        (begin
          (pk 'syntax #'thing 'pair? (pair? #'thing))
          (pk 'car (car #'thing)))))))

(mysyntax (c d))


results in


;;; (syntax (#<syntax a> #<syntax b>) pair? #t)

;;; (car #<syntax a>)

;;; (syntax #<syntax:test.scm:13:10 (c d)> pair? #f)
Backtrace:
            7 (primitive-load "/home/jean/repos/lilypond/build/test.s…")
In ice-9/eval.scm:
    721:20  6 (primitive-eval (mysyntax (c d)))
In ice-9/psyntax.scm:
   1229:36  5 (expand-top-sequence (#<syntax:test.scm:13:0 (mysynta…>) …)
   1121:20  4 (parse _ (("placeholder" placeholder)) ((top) #(# # …)) …)
   1342:32  3 (syntax-type (mysyntax #<syntax:test.scm:13:10 (c d)>) # …)
   1562:32  2 (expand-macro #<procedure 7fa6fa335320 at ice-9/eval.s…> …)
In ice-9/eval.scm:
     159:9  1 (_ #(#(#<directory (guile-user) 7fa6fa3dfc80>) #<synt…>))
     155:9  0 (_ _)

ice-9/eval.scm:155:9: In procedure car: Wrong type argument in position 
1 (expecting pair): #<syntax:test.scm:13:10 (c d)>


Why does one syntax object look like a pair and not the other?
What is the difference between the two cases?

Thanks,
Jean




             reply	other threads:[~2022-04-04 23:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 23:00 Jean Abou Samra [this message]
2022-04-05 18:23 ` Syntax objects as traditional pairs Linus Björnstam

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=1024dc44-d9f2-80b5-4b26-01a3779052ee@abou-samra.fr \
    --to=jean@abou-samra.fr \
    --cc=guile-user@gnu.org \
    /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).