[R6RS] libraries

Manuel Serrano Manuel.Serrano
Wed Dec 7 04:29:37 EST 2005


> > Are you using a unique environment for 
> > macros and variables? In other words, do you mean that it is an
> > error to define a macro and a variable with the same name?
> 
> Yes. It seems that we simply disagree on this point.
Yes. I'm afraid that we disagree. The problem, I think, is that the current
design relies on this merged namespace. Without it, how do you handle
intuitively:

  <body> = <impexp-form>* <comdef-form>*

You could imagine a kind of virus such as:

(library <lpath> <lang> 
  (export export)

  (define (export . l) <do something nasty>))

To me, the solution to this problem is not to enforce a unique namespace
but to give more structure to library. For instance, I think that an 
alternative design could be:

(library <lpath> <lang> (<impexp-form>*) <body>)


> > If I understand you correctly:
> > 
> > (library <lib-path> <language>
> >   (define (odd x) ... (even x) ...)
> >   (define (even x) ... (odd x) ...)
> >   (odd 5)
> >   )
> > 
> > is correct, but
> > 
> > (library <lib-path> <language>
> >   (define (odd x) ... (even x) ...)
> >   (odd 5)
> >   (define (even x) ... (odd x) ...)
> >   )
> > 
> > is incorrect. Right?
> 
> Right.
Okay. I can live with that but I would like to known if everyone here,
agrees.

> > > I think the `library' form has to work well with macros, or it won't be
> > > a useful standard (and "work well" to me means "obeys lexical scope").
> > > If there's disagreement on this point, we should certainly discuss it
> > > further.
> > I imagine that I will be pretty alone on this side but no, I don't
> > think that I want to enforce macros to use lexical scoping. I think
> > that, at least, we should not specify this in the library specification. In
> > particular, I think that we can adopt SYNTAX-CASE. We can specify that
> > macros defined with SYNTAX-CASE are hygienic but I don't think that we
> > should specify that a Scheme that uses traditional Lisp macros cannot
> > be R6Rs because of the specification of the LIBRARY form. 
> 
> If an implementation supports defmacro, then certainly such macros
> wouldn't be required to obey lexical scope. Where the SRFI says
> "macros", I had in mind "macros defined using standard mechanisms",
> which I expect to be `syntax-rules' and `syntax-case'. In any case, I
> think the library and macro standard parts of the will have to
> reference each other.
May be but do you think that dropping the paragraph above would really
change something for the comprehension and description of the libraries.

 "Macro expansion obeys lexical scope in the sense that if a macro
 expansion introduces a identifier that is bound in the context of the
 macro definition, it refers to the binding in the environment of the
 macro-definition library, not in the environment of the expansion."

I have another remark that I have already made but I would like everybody's
opinion. This remark is about interpreter vs compiler. I imagine that
we are going to support the function EVAL. In a library such as:

(library <lpath> <lang> 
  (import <lpath2>)
  (define (foo ...) ...)
  (eval))

What is the environment of eval? Is FOO bound? Are the bindings exported
by <lpath2> available? I have a problem with a positive answer to this 
question. In a compiled environment, how would it still be possible to produce
compact applications? (By compact, I mean applications that don't carry
the entire R6Rs library with them.)

-- 
Manuel


More information about the R6RS mailing list