unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: syntax-local-value patch for discussion
Date: Mon, 23 Jan 2012 17:06:09 +0100	[thread overview]
Message-ID: <CAGua6m08aTgtuD5yNuz3p2OSKp=M4+xpK_Q5=_B1C_iFE1kuAg@mail.gmail.com> (raw)
In-Reply-To: <87pqeapu4o.fsf@pobox.com>

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

Ok, here is a discussoin using code in syntax-parse.

Let's start with the defintion of a syntax-class, str in the macro package
syntax-parse:
(define-syntax-class str #:attributes () #:opaque #:commit
  #:description "string"
  (pattern (~and x (~fail #:unless (string? (syntax-e #'x))))))

So the and patterns first match x and then on the same element match a ~fail
that fails if the supplied code (string? (syntax-e #'x)) is false.

The headake for me is that #'(string? (syntax-e #'x)) is stored in a struct
and hence
does not get wrapped correctly e.g. after the packaging of this code in a
struct, say S
we will then issue something like the following code in the expansion of
the first match

#'(with-syntax ((x  stx))  (parse stx S))

and when parse is ready to unpack S we could have

S = #(syntax-object #<struct-s> wrap-part hygiene)

Now I basically solve this problem by constructing
a = (vector 'syntax-object (vector-ref (struct-s-code (syntax->datum S)) 1)
(un-mark wrap-part) hygiene)
crossing the fingers that the "code" will be nonatomic and then the
expander will use it like,

(with-syntax ((code a)) #'( .... code))

This is the story. I do not want to rest here because this solution is not
resistant to bitrot and depends on internals that I do not want to touch.
The solution would be to have an interface in guile that allows to write,

(with-syntax ((code (syntax-embedd (struct-s-code (syntax->datum S)) S)))
(.... code ...))

e.g.

(syntax-embedd exp env-stx) = embedds exp in the syntax env-stx

I'm much more fine with dropping env-stx and replace that with the
equivalent syntax environment at the macro call

I Hope that things are less foggy now!

Regards
Stefan




On Mon, Jan 23, 2012 at 11:53 AM, Andy Wingo <wingo@pobox.com> wrote:

> Hi Stefan,
>
> On Thu 19 Jan 2012 10:50, Stefan Israelsson Tampe <stefan.itampe@gmail.com>
> writes:
>
> > Working on porting syntax-parse is a learning experience and I know
> > understand how it uses syntax-local-value as a way to lookup a syntax
> > object by joining the wraps together with the total wrap at the macro
> > call.
>
> syntax-local-binding just uses the wrap from the id that you give it,
> without joining it to the macro expansion environment's wrap.
>
> > I would like to have a syntax-join function that takes two syntax
> > objects and join them correctly and robustly in the pressense of
> > eventual marks or not.
>
> Why would you want to do something like this?
>
> You might try writing the documentation of the function first; it would
> clarify the conversation.
>
> Regards,
>
> Andy
> --
> http://wingolog.org/
>

[-- Attachment #2: Type: text/html, Size: 3360 bytes --]

  reply	other threads:[~2012-01-23 16:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-05 18:12 syntax-local-value patch for discussion Stefan Israelsson Tampe
2011-12-08 21:58 ` Ian Price
2011-12-09 11:49   ` Stefan Israelsson Tampe
2012-01-07  0:05 ` Andy Wingo
2012-01-08 17:47   ` Stefan Israelsson Tampe
2012-01-08 19:15 ` Mark H Weaver
2012-01-08 21:28   ` Stefan Israelsson Tampe
2012-01-14 16:42   ` Stefan Israelsson Tampe
2012-01-19  9:50     ` Stefan Israelsson Tampe
2012-01-23 10:53       ` Andy Wingo
2012-01-23 16:06         ` Stefan Israelsson Tampe [this message]
2012-01-26 11:31           ` Andy Wingo
2012-01-26 15:49             ` Stefan Israelsson Tampe

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='CAGua6m08aTgtuD5yNuz3p2OSKp=M4+xpK_Q5=_B1C_iFE1kuAg@mail.gmail.com' \
    --to=stefan.itampe@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=wingo@pobox.com \
    /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).