From: Mark H Weaver <mhw@netris.org>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] Improved source properties and errors; => within case
Date: Wed, 08 Feb 2012 11:16:40 -0500 [thread overview]
Message-ID: <87bop98fmf.fsf@netris.org> (raw)
In-Reply-To: <87fwel1vxr.fsf@pobox.com> (Andy Wingo's message of "Wed, 08 Feb 2012 11:06:08 +0100")
Hi Andy, thanks for the quick review!
Andy Wingo <wingo@pobox.com> writes:
> Patch set looks good to me. Please push.
Great, thanks! Of course I'll fix the following issues first.
> On Wed 08 Feb 2012 10:09, Mark H Weaver <mhw@netris.org> writes:
>
>> The way that source properties are stored means that Guile can only
>> -associate source properties with parenthesized expressions, and not, for
>> -example, with individual symbols, numbers or strings. The difference
>> -can be seen by typing @code{(xxx)} and @code{xxx} at the Guile prompt
>> -(where the variable @code{xxx} has not been defined):
>> +associate source properties with parenthesized expressions and non-empty
>> +strings, and not, for example, with individual symbols or numbers. The
>> +difference can be seen by typing @code{(xxx)} and @code{xxx} at the
>> +Guile prompt (where the variable @code{xxx} has not been defined):
>
> This isn't quite right; #*101010101 should probably get source info, no?
Yes, and indeed this patch _does_ add source info for bitvectors, but
I forgot to mention that in the doc. I'll fix it.
> And is it useful to have an exception for empty strings? I would think
> that it would be fine to return fresh empty strings. The compiler would
> DTRT. I don't care much though.
Currently 'read' returns the shared global 'scm_nullstr' for empty
strings. We could remove that optimization though. Maybe we should.
What do you think?
> Perhaps: "Everything but numbers, symbols, characters, and booleans get
> source information." Dunno.
and keywords, and maybe some other things we're forgetting. Good idea.
Another option is to explain it in terms of the core problem: only types
for which 'read' reliably returns a fresh object can have source
properties. I'll think on this some more.
>> + (syntax-case whole-expr ()
>> + ((_ clause clauses ...)
>> + #`(begin
>
> (This is in `cond'). Why is the begin needed here?
It's needed because the 'loop' returns a _list_ of expressions (of
length zero or one), to enable more graceful handling of the base case.
The outer 'loop' is guaranteed to return a list of length one, so I need
to either take the 'car' or wrap it in a 'begin'.
>> + #`((let ((t test))
>> + (if t t #,@tail)))))
>
> Use `or' here.
I can't, because if it's the last clause, 'tail' will be '(), which
would generate (or test) which would be incorrect. (or test) would
return #f is 'test' is false, but we actually want to return
*unspecified* in that case.
>> + (syntax-case whole-expr ()
>> + ((_ expr clause clauses ...)
>> + (with-syntax ((key #'key))
>> + #`(let ((key expr))
>> + #,@(fold
>
> (In `case'.) Likewise here, it would be good to avoid this use of an
> implicit `begin', of possible.
Hmm. I don't know if this is what you meant, but it occurs to me that
as I've currently implemented them, both (cond (else (define x 5) x))
and (case 1 (else (define x 5) x)) are allowed. I'll have to make sure
that those raise errors. I guess that means I'll have to insert a '#f'
like I did for local-eval. Do you see a better way?
Thanks!
Mark
next prev parent reply other threads:[~2012-02-08 16:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-08 9:09 [PATCH] Improved source properties and errors; => within case Mark H Weaver
2012-02-08 10:06 ` Andy Wingo
2012-02-08 16:16 ` Mark H Weaver [this message]
2012-02-08 21:27 ` Noah Lavine
2012-02-08 22:30 ` Mark H Weaver
2012-02-10 15:45 ` Ludovic Courtès
2012-02-11 20:23 ` Mark H Weaver
2012-02-11 21:08 ` Ludovic Courtès
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=87bop98fmf.fsf@netris.org \
--to=mhw@netris.org \
--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).