[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Syntax object representation
From: |
Taylan Ulrich Bayirli/Kammer |
Subject: |
Re: Syntax object representation |
Date: |
Mon, 23 Jun 2014 20:30:08 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Dmitry Bogatov <address@hidden> writes:
> Hello.
>
> How stable the fact, that
> (equal? #'(foo bar) (list #'foo #'bar))
> ?
Not stable. A syntax object for a list can also wrap the whole list, it
is not necessarily a list of syntax objects.
E.g. the following is a valid syntax object representing '(+ 1 2)':
#(syntax-object (+ 1 2) ((top)) (hygiene guile-user))
> Why? Combining two syntax objects in list can be done via
> #` and #, but it would be nice to know, than I am free
> to use all power of list functions.
A syntax object like the above example for '(+ 1 2)' could contain
source-location or other meta-data. If we guarantee that all non-atomic
syntax objects are lists, we lose that ability. It's better that they
are "opaque" and that 'syntax-case' or other special operators are the
only way to "destructure" them.
> Also, it seems there is no syntax-object? predicate. Is it by design?
Guile uses psyntax, so syntax objects are actually just vectors! :)
You can enter the following in the Guile REPL and see what happens:
#(syntax-object (+ 1 2) ((top)) (hygiene guile-user))
Note that it's not the same as:
'#(syntax-object (+ 1 2) ((top)) (hygiene guile-user))
(This one is quoted, so it's just a literal vector.)
> It seems, than syntax->datum is no-op on non-syntax objects.
> Can I rely on it?
I think that's also an implementation detail of psyntax. I wouldn't
rely on it, but I'm not sure on this one.
> Thanks in advance.
Happy to help!
> --
> Best regards, Dmitry Bogatov <address@hidden>,
> Free Software supporter, esperantisto and netiquette guardian.
> git://kaction.name/rc-files.git
> GPG: 54B7F00D
Taylan