larcenists / larceny

Larceny Scheme implementation
Other
202 stars 32 forks source link

A library named `rename` cannot be imported, and any library cannot define `rename` #773

Closed mnieper closed 7 years ago

mnieper commented 8 years ago

The following two issues (tested in R7RS mode with version 0.99) may be related:

Error: unhandled condition:
Compound condition has these components: 
#<record &who>
    who : rename
#<record &message>
    message : "Invalid form"
#<record &syntax>
    form : (rename)
    subform : #f

As soon as rename is defined at the REPL, the import works.

Error: unhandled condition:
Compound condition has these components: 
#<record &who>
    who : define
#<record &message>
    message : "Redefinition of identifier in body"
#<record &syntax>
    form : (define rename 'a)
    subform : rename
WillClinger commented 8 years ago

The first issue is an unfortunate consequence of hygiene: rename has a specific meaning within import forms that is incompatible with its use as a library name. Redefining rename at the REPL removes its usual meaning, making it available as a library name.

The second issue is a consequence of forbidding redefinitions of imported identifiers within library bodies, which are unlike top-level programs and REPLs in that respect. Perhaps that prohibition should be weakened, which is why I am leaving this issue open without assigning it a milestone.

mnieper commented 8 years ago

Shouldn't this be marked as a bug (or as a deviation from the R7RS)? The identifier rename should not be bound by default in a library body.

WillClinger commented 8 years ago

Yes, the first issue is a bug. The components of library names are symbols or exact non-negative integers, and should have nothing to do with the denotation of the identifier rename that's used when matching import sets or exports. The components of library names should be treated the same as field names in records.

WillClinger commented 7 years ago

Fixed by changeset 582c6082f1bbdfadc29d61e9848037d837b01d63