unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: mikael@djurfeldt.com
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: Fixing the slib mess
Date: Mon, 22 Oct 2012 17:51:29 -0400	[thread overview]
Message-ID: <87mwze18gu.fsf@tines.lan> (raw)
In-Reply-To: <CAA2XvwKDtWW7ryQ8rLoaLekNtyLpLaHOs4U_qF7Coy+VkJ-xPg@mail.gmail.com> (Mikael Djurfeldt's message of "Mon, 22 Oct 2012 01:11:47 +0200")

Hi Mikael!

It's great to see you on guile-devel again, and it would be good to have
a working slib on Guile 2.  Thanks for working on this :)

Mikael Djurfeldt <mikael@djurfeldt.com> writes:
> Comments?  Can I add syntax-toplevel? to psyntax.scm and (system
> syntax)?

FWIW, it sounds reasonable to add something like 'syntax-toplevel?'.
However, if it's going to be added as a public API, we ought to be
careful to get it right.  Consider this top-level form:

  (let-syntax ((foo (syntax-rules () ((foo x) (quote x)))))
    (define bar (foo (a b))))

Here, although the 'define' is expanded within a non-toplevel syntactic
environment, after expansion it ends up within a top-level environment,
and indeed 'bar' becomes a top-level binding.  That's because the body
of a 'let-syntax' or 'letrec-syntax' gets spliced into the outer
context, sort of like a 'begin' but with some syntax bindings added.

It looks to me like your current implementation of 'syntax-toplevel?'
is actually testing for a top-level _syntactic_ environment, but what
you ought to be testing for here is slightly different.  I'm not sure
what is the proper term, but for now I'll call it a top-level
_execution_ environment.

I'm also not quite sure how best to test for a top-level execution
environment.  I'm not sure whether the wrap contains enough information
to determine that.

It might be easier to handle this with 'define-syntax-parameter' and
'syntax-parameterize'.  The idea would be that within slib, 'define'
would be a syntax parameter.  Its default expansion would turn it into
'define-public', and also parameterize 'define' to mean 'base:define'
within the body.  If needed, you could also define 'let' and maybe some
other things to parameterize 'define' within the body.

Another option would be to make 'export' a syntax parameter, and
parameterize it to a no-op within lexical contours such as 'define' and
'let'.

What do you think?

> I should also say that I have not yet fixed the slib interface to the
> new Guile uniform arrays, so there's a lot of slib functionality which
> won't yet work.

I happen to be working on the reader lately.  Would it help to implement
SRFI-58 in our reader?  Note that SRFI-58 array notation conflicts with
Guile's own array notation, e.g. #1a("a" "b") is legal in both syntaxes
and means different things.  So we'd need to use a reader-directive such
as #!srfi-58 to change the reader mode on that port.  Would that help?

Thanks for working on this!

     Regards,
       Mark



  parent reply	other threads:[~2012-10-22 21:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-21 23:11 Fixing the slib mess Mikael Djurfeldt
2012-10-22 18:31 ` Stefan Israelsson Tampe
2012-10-22 19:11   ` Mikael Djurfeldt
2012-10-22 19:33     ` Stefan Israelsson Tampe
2012-10-22 20:00 ` Mikael Djurfeldt
2012-10-22 21:51 ` Mark H Weaver [this message]
2012-10-23  8:23   ` Mikael Djurfeldt
2012-10-23 18:01     ` Mark H Weaver
2012-10-23 22:23       ` Mikael Djurfeldt
2012-11-01  5:25         ` Mark H Weaver
2013-01-21 17:58 ` Andy Wingo
2013-01-21 18:09   ` Mikael Djurfeldt
2013-01-21 19:04     ` Andy Wingo

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=87mwze18gu.fsf@tines.lan \
    --to=mhw@netris.org \
    --cc=guile-devel@gnu.org \
    --cc=mikael@djurfeldt.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).