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: Precedence for reader extensions
Date: Tue, 19 Feb 2013 10:41:02 -0500	[thread overview]
Message-ID: <87a9r0gvld.fsf@tines.lan> (raw)
In-Reply-To: <CAA2Xvw+QsHP4jPNYW_GpnHsiRBKuojDW=1f=+AtC=JQVZ6NXLQ@mail.gmail.com> (Mikael Djurfeldt's message of "Tue, 19 Feb 2013 11:14:03 +0100")

Mikael Djurfeldt <mikael@djurfeldt.com> writes:
> On Tue, Feb 19, 2013 at 12:33 AM, Mark H Weaver <mhw@netris.org> wrote:
>> Mikael Djurfeldt <mikael@djurfeldt.com> writes:
>>> I propose to simplify this to only two levels:
>>>
>>> 1. %read-hash-procedures
>>> 2. predefined syntax
>
> It turns out that the change I propose above was already implemented
> in read.c.  The effect just wasn't visible due to a bug in flush_ws
> which caused all #! to be erroneously removed if they exist as the
> outermost expression.

I'm not sure that I consider this a bug.  All of the tokens that
flush_ws removes can appear anywhere that whitespace is allowed, and are
considered whitespace to the caller (although reader directives may
modify the per-port reader options as a side-effect).

  #;<expr>     (sexp-comments)
  #!fold-case  (reader directives)
  #! ... !#    (shebang block comments)
  #| ... |#    (r6rs block comments)

> In the attached diff, I've fixed the flush_ws bug and cleaned up some
> garbage code in scm_read_sharp which was unreachable.
>
> Can I push this into the repository?

I'm uncomfortable with globally overriding standard read syntax.  In a
large scheme system such as Guile, there are many modules that use
'read' and expect it to act in accordance with standard lexical
conventions.

Therefore, I'd prefer to limit 'read-hash-extend' to adding new syntax
that would otherwise have been considered an error.  If you're going to
override standard read syntax, then I think it should only be done on a
per-port basis.

Therefore, I'd prefer a precedence closer to this:

  1. (possibly) per-port variant of %read-hash-procedures
  2. predefined syntax
  3. %read-hash-procedures

>> I don't think this would be sufficient.  The problem is that tokens of
>> the form "#!<symbol><delimiter>" have become standardized.  To name a
>> few examples, both R6RS and R7RS define the reader directives
>> #!fold-case and #!no-fold-case, R6RS has #!r6rs, and SRFI-105 has
>> #!curly-infix.  Guile also has #! ... !# block comments to help with the
>> handling of executable scripts.
>
> In what sense is it not sufficient?  In any case: The present diff
> doesn't remove any functionality or make performance worse.  It only
> removes some inconsistent behavior.  At the same time it allows
> support for mit-scheme #!optional and #!rest.

The problem with this approach is that it does not compose.  You want to
add #!optional and #!rest.  R6RS added #!r6rs, #!fold-case, and
#!no-fold-case.  SRFI-105 added #!curly-infix.  But there can be only
one read-hash-procedure for #!, and it's global to the entire system.

That's why I suggested a way to add new tokens of the form
"#!<symbol><delimiter>".  That way, you could add handlers for #!rest
and #!optional without interfering with the other #!<symbol><delimiter>
tokens.

What do you think?

    Regards,
      Mark



  reply	other threads:[~2013-02-19 15:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-18 21:05 Precedence for reader extensions Mikael Djurfeldt
2013-02-18 21:07 ` Mikael Djurfeldt
2013-02-18 21:26 ` Mikael Djurfeldt
2013-02-18 21:42   ` Mikael Djurfeldt
2013-02-18 23:33 ` Mark H Weaver
2013-02-19 10:14   ` Mikael Djurfeldt
2013-02-19 15:41     ` Mark H Weaver [this message]
2013-02-19 16:42       ` Mikael Djurfeldt
2013-02-19 16:58         ` Mikael Djurfeldt
2013-02-20 14:21           ` Ludovic Courtès
2013-02-22  2:52           ` Mark H Weaver
2013-02-22  9:36             ` Mikael Djurfeldt
2013-02-22 15:45               ` Ludovic Courtès
2013-02-22 15:54             ` Ludovic Courtès
2013-02-19 23:51         ` Mikael Djurfeldt

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=87a9r0gvld.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).