Closed higepon closed 2 years ago
Or, just implement cond-expand
as separately implemented macro that is exported through (scheme base)
, (srfi 0)
and (srfi :0)
so we can possibly exclude cond-expand
from program ..? In other words, do we want to allow cond-expand
to choose imported libraries(I don't think so but can be otherwise.)
R7RS standard just describes cond-expand
outside of library declarations is a one of (scheme base)
definition. If we had proper (features)
procedure during expand
phase(of R6RS macro expansion), cond-expand
(of (scheme base)
) should be able to be implemented upon R6RS expander.
OTOH, applying R7RS expander with R6RS top-level shouldn't be harmful aside cond-expand
scoping.
I need some more details to understand what you meant but here is my thought. In my understanding we have to support the following in a R7RS scheme program.
None of them are supported in psyntax. (B) and (C) are somewhat supported but not exactly the same. So I was wondering if we just write small top level program converter (similar to the library converter but smaller). Same as the library converter, we convert top level program right before we start psyntax expander.
I prefer this way just because
In other words, do we want to allow cond-expand to choose imported libraries
No I don't think so. Per R7RS "A Scheme program consists of one or more import decla- rations followed by a sequence of expressions and definitions. ". So we don't need to support that case. IMO it's not necessary.
I think I can come up with a working prototype in a few days. So let's see how it goes. But I would like your input here.
Two-pass expander need to consider some extreme case. e.g.)
(import (rename (scheme base) (include myinclude)))
(define (include x) #t)
(myinclude "hoge.scm") ;; => should we treat this as (include "hoge.scm") ?
(include "hoge.scm") ;; => #t? or treat this as (include "hoge.scm") ?
Perhaps we'd need to check other R6RS+R7RS implementations such as Guile3, Sagittarious and Ypsilon.
Yeah. You're right. The case is tricky and I'm not sure what is expected there. I think my priority now is "works for most of the use cases". But we should look into other implementation. They might have smart solution for it.
Expand top level program with R7RS expander so that proper cond-expand in top level program works.