unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Christopher Allan Webber <cwebber@dustycloud.org>
Cc: Guile Devel <guile-devel@gnu.org>
Subject: Re: Including sjson (formerly (ice-9 json)) and fash.scm in guile proper?
Date: Tue, 20 Jun 2017 19:18:35 -0400	[thread overview]
Message-ID: <87injqmeno.fsf@netris.org> (raw)
In-Reply-To: <87mv92mg2v.fsf@netris.org> (Mark H. Weaver's message of "Tue, 20 Jun 2017 18:47:52 -0400")

I wrote:

> I was also looking for a cleaner way to express this parser, and to add
> better error reporting, while allowing flexibility for users to
> customize the Scheme representation.

I forgot to mention that another goal was to minimize heap allocations,
e.g. eliminating the allocation of intermediate lists of characters or
digits.

>   (define (read-array port)
>     "Read a JSON array from PORT and return the result of calling
> ARRAY-FINALIZE on the final seed produced using ARRAY-KNIL and
> ARRAY-KONS."
>     (match-next* port
>       (#\[ (match-next* port
>              (#\] array-knil)
>              (else (let ((seed (read-array-elements array-knil port)))
>                      (match-next* port
>                        (#\] (array-finalize seed)))))))))

Sorry, I forgot to apply 'array-finalize' in the empty-array case.
Here's a corrected version:

  (define (read-array port)
    "Read a JSON array from PORT and return the result of calling
ARRAY-FINALIZE on the final seed produced using ARRAY-KNIL and
ARRAY-KONS."
    (array-finalize
     (match-next* port
       (#\[ (match-next* port
              (#\] array-knil)
              (else (let ((seed (read-array-elements array-knil port)))
                      (match-next* port
                        (#\] seed)))))))))

      Mark



  reply	other threads:[~2017-06-20 23:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08 23:17 Including sjson (formerly (ice-9 json)) and fash.scm in guile proper? Christopher Allan Webber
2017-05-12 19:15 ` Mark H Weaver
2017-05-14  1:30   ` Christopher Allan Webber
2017-05-15 18:35     ` Mark H Weaver
2017-05-15 19:53       ` Christopher Allan Webber
2017-06-20 22:47         ` Mark H Weaver
2017-06-20 23:18           ` Mark H Weaver [this message]
2017-06-20 23:50           ` Mark H Weaver
2017-06-22 16:26           ` Christopher Allan Webber
2017-06-03 13:35 ` 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=87injqmeno.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=cwebber@dustycloud.org \
    --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).