unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Matt Wette <matt.wette@gmail.com>
To: Mark H Weaver <mhw@netris.org>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: problems with syntax-case and with-syntax
Date: Wed, 20 Sep 2017 05:50:19 -0700	[thread overview]
Message-ID: <89D4027A-4E40-4CC0-9C14-4C4974E9AF96@gmail.com> (raw)
In-Reply-To: <33BDE2DC-09AB-4DBF-AD42-9929CE936F79@gmail.com>


> On Sep 18, 2017, at 6:16 AM, Matt Wette <matt.wette@gmail.com> wrote:
> 
>> 
>> On Aug 27, 2017, at 6:35 PM, Mark H Weaver <mhw@netris.org> wrote:
>> 
>> Mark H Weaver <mhw@netris.org> writes:
>> 
>>> The problem is that in Guile 2.2, whenever (define <id> ...) is found in
>>> the expanded code, where <id> was introduced by a macro (i.e. not passed
>>> as an explicit argument to the macro), Guile will rewrite the <id> into
>>> a new name based on the hash of the entire definition form.
>> 
>> I forgot to mention that only top-level definitions are munged in this
>> way.
>> 
>> Also, my parenthetical definition of what it means to be "introduced by
>> a macro" lacked precision.  To avoid <id> being "introduced by a macro",
>> it's not enough for <id> to have been passed an argument to the macro
>> that generated the definition.  If that were the case, you could work
>> around this by adding an additional layer of macros, where the upper
>> layer generated <id> and passed it down to the lower layer which would
>> generate the definition.
>> 
>> To avoid <id> being considered "introduced by a macro", <id> must
>> ultimately occur verbatim in the source code outside of any macro
>> template.
> 
> I have read through the posts, and the Guile 2.2 ref manual.  The explanations
> are not quite complete in my mind.  If all top-level id's introduced by macros
> were munged, then it would break a lot of existing code.  See, for example,
> the `define-structure' example in "The Scheme Programming Language", 4th ed.
> It seems identifiers introduced by datum->syntax are preserved, as long 
> as they are not redefined.  Is that correct?
> 
> In my case, I was redefining by architecture (or convention). I was generating 
> "wrap-" + <identifier> in a macro that called a another macro that made the same 
> definition.  Is it bad form to assume an convention like this?
> 
> Off to do more reading on this: Dybvig's paper on syntax-case and I have the 
> book too.  and R6RS ...

I have been convinced that introducing top-level definitions is bad form, so I will 
be removing datum->syntax calls but stuffing some procedures into the associated 
struct, I think.  So instead of

  (define-fh-type foo_t)
  ...
  (unwrap-foo_t obj)

I will use

  (define-fh-type foo_t
     foo_t? make-foo_t)
  ...
  (fh-unwrap foo_t obj)

Matt





  reply	other threads:[~2017-09-20 12:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-27 20:18 problems with syntax-case and with-syntax Matt Wette
2017-08-28  0:36 ` Mark H Weaver
2017-08-28  1:35   ` Mark H Weaver
2017-09-18 13:16     ` Matt Wette
2017-09-20 12:50       ` Matt Wette [this message]
2017-08-28  3:48   ` Matt Wette
2017-08-28  3:50   ` Matt Wette
2017-08-28 11:38   ` Chris Vine

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=89D4027A-4E40-4CC0-9C14-4C4974E9AF96@gmail.com \
    --to=matt.wette@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=mhw@netris.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).