guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Don't mix definitions and expressions in SRFI-9


From: Andreas Rottmann
Subject: Re: [PATCH] Don't mix definitions and expressions in SRFI-9
Date: Mon, 07 Mar 2011 01:31:10 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

address@hidden (Ludovic Courtès) writes:

> Hi Andreas,
>
> Andreas Rottmann <address@hidden> writes:
>
>> The expansion of `define-inlinable' contained an expression, which made
>> SRFI-9's `define-record-type' fail in non-toplevel contexts ("definition
>> used in expression context").
>
> SRFI-9 says “Record-type definitions may only occur at top-level”, and
> I’m inclined to stick to it.  If we diverge, then people could write
> code thinking it’s portable SRFI-9 code while it’s not.
>
I can certainly relate to that, and agree that it's a good principle,
however, see below.

> How about adding a ‘let-record-type’ or similar in (srfi srfi-9 gnu)?
>
The issue is not that I'm explictly writing code that uses
`define-record-type' in a non-toplevel context, but that I have a
testing framework (built upon Riastradh's trc-testing), which uses R6RS
`eval' to load testcases.  Since `eval' does not allow for the code to
be evaluated to be in a top-level context, I'm using this:

(eval `(let () ,@code-to-be-tested) the-environment-for-the-code)

Now `code-to-be-tested' can't contain any SRFI-9 record definitions if
the literal interpretation of SRFI-9 is used, even if that code would
run perfectly fine if entered at the REPL or being executed as an R6RS
script (modulo the import statement, but the test runner can work around
that).  This is certainly a special use case, but I think it is
reasonable one.

Regards, Rotty
-- 
Andreas Rottmann -- <http://rotty.yi.org/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]