unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Richard Todd <richardt@vzavenue.net>
Cc: guile-devel@gnu.org
Subject: Re: keyword cleanup patch
Date: Sat, 10 Jan 2004 18:53:43 -0600	[thread overview]
Message-ID: <20040111005343.GA736@Richard-Todds-Computer.local> (raw)
In-Reply-To: <xfyr7y73hgx.fsf@csserver.evansville.edu>


[-- Attachment #1.1.1: Type: text/plain, Size: 2377 bytes --]

On Sat, Jan 10, 2004 at 10:18:22AM -0600, Stephen Compall wrote:
> Richard Todd <richardt@vzavenue.net> writes:
> 
> > Why are both syntaxes allowed in this one area, anyway?  I assume
> > it's a historical reason?  It's inconsistent with the rest of guile
> > (AFAIK) where you have to set a reader option for this behavior.
> 
> On the syntax: Emacs Lisp uses plain `:' for keywords; other lisps may
> do so as well.  Incidentally, `#:' in front of a symbol in elisp will
> prevent its interning. :)

That doesn't explain why special code in boot-9 allows #: or : in
specific statements like (define-module), does it?  I may not be fully
grasping what you are getting at.

I've searched with google, and the only explanation I can find is that
several guile developers prefer :.  I'm fine with that sentiment, but
guile's current state doesn't actually help these people, IMO.

The main problem, as I see it, is that people can't use : in code they
would release, because they can't assume that users are using the
optional reader setting.  Setting the option for the users would be
disgusting, and potentially break their code.

In my fledgling library of modules, I added a module which lets you do:

(define-module (xxx) :use-syntax (guile-syntax colon-keyword))

...and for this module you can code to your preference.  Users need
not even know about a reader extension (in fact, I took the extension
itself out of my local guile tree, on principle!).

To me, this is a sane answer.  Plus, this approach can be extended to
support 'keyword:' (as in DSSSL), or '&keyword', etc, without changing
the scheme reader.  Of course you take a speed hit compared to the
reader option, but there are ways to help with that if it became an
issue.

(And though I may be alone, and have not done any research on this
issue, I don't see why an elisp reader has to be grafted on to the
scheme reader.  Aside from the oh-so-close-to-scheme elisp case, if
guile really wants to seamlessly support other languages, it needs a
way to load a module with a different reader entirely, anyway.  A
separate elisp reader could still share code with the scheme reader, I
would think, and would be a cleaner answer).

The proof-of-concept (read: room for improvement!) module I described
is attached, for any who might be interested.

Richard Todd

[-- Attachment #1.1.2: colon-keyword.scm --]
[-- Type: text/plain, Size: 802 bytes --]

(define-module (guile-syntax colon-keyword) #:export (colon-keyword))

(define (colon-keyword exp)
  (let lp ((lst exp))
    (cond 
     ((null? lst) exp)
     ((pair? lst)
      (set-car! lst (colon-keyword (car lst)))
      (if (pair? (cdr lst))
          (lp (cdr lst))
          (begin (set-cdr! lst (colon-keyword (cdr lst)))
                 (lp '()))))
     ((symbol? lst)
      (let ((str (symbol->string lst)))
        (if (char=? (string-ref str 0) #\:)
            (symbol->keyword (string->symbol (substring str 1)))
            lst)))
     ((vector? lst)
      (let lp2 ((i 0))
        (if (>= i (vector-length lst))
            lst
            (begin (vector-set! lst i (colon-keyword (vector-ref lst i)))
                   (lp2 (+ i 1))))))
     (else lst))))


[-- Attachment #1.2: Type: application/pgp-signature, Size: 186 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

  reply	other threads:[~2004-01-11  0:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-08 12:25 keyword cleanup patch Richard Todd
2004-01-10 12:48 ` Neil Jerram
2004-01-12 17:31   ` Marius Vollmer
2004-01-10 16:18 ` Stephen Compall
2004-01-11  0:53   ` Richard Todd [this message]
2004-01-12 16:59 ` Marius Vollmer

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=20040111005343.GA736@Richard-Todds-Computer.local \
    --to=richardt@vzavenue.net \
    --cc=guile-devel@gnu.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).