Subject: Re: bug#11198: problems reading data with a "read-hash-extend" registered reader

From: Klaus Stehle <[email-masked]>
Date: Wed, 11 Apr 2012 22:34:07 +0200 (CEST)

Hallo Mark,

On Wed, 11 Apr 2012, Mark H Weaver wrote:

> Date: Wed, 11 Apr 2012 15:33:32 -0400
> From: Mark H Weaver <[email-masked]>
> To: Ludovic Courtès <[email-masked]>
> Cc: Klaus Stehle <[email-masked]>, [email-masked]
> Subject: Re: bug#11198: problems reading data with a "read-hash-extend"
>     registered reader
> 
> [email-masked] (Ludovic Courtès) writes:
> > Klaus Stehle <[email-masked]> skribis:
> >
> >> (read-hash-extend #\R read-R)
> >
> > Unlike previous versions, Guile 2.0 has distinct compilation and
> > run-time phases.  Here you probably want the reader extension to become
> > effective at compile-time (when compiling), and at evaluation-time (when
> > interpreting the code):
> >
> >   (eval-when (compile eval)
> >     (read-hash-extend #\R read-R))
> 
> I don't think this will be sufficient by itself, because 'read-R' will
> not yet be bound at compile time.  You also need to define 'read-R'
> within the 'eval-when', and everything else that's needed to run
> 'read-R'.

You are right. But now the record type is unknown at compile time.
So I also wrap the define-record-type expression into an 'eval-when'.

Then we arrive at the same error message which is displayed when
typing the #R-expression interactively:

=> ERROR: build-constant-store: unrecognized object
=> #<my-record one: "bla" two: "bobo">

This error message is not very informative. And in spite of an error the
record is built! You can see it in the error message but you can't use it.

> Alternatively, you could refrain from using the #\R syntax within the
> same file where it is defined.

Not yet tested ...  (soon ...)

Thanks,
Klaus