Skip to content

Use-site binder hygiene bug for let #474

@michaelballantyne

Description

@michaelballantyne

I've previously discussed this with @mflatt , but I figure I should make a ticket.

Consider this program:

#lang rhombus/and_meta

block:
  let x = "outer"
  defn.macro 'm $id':
    'let $id = "inner"
     x'
  m x

It returns "inner", but I think it should return "outer" like the similar Racket program does:

(define x "outer")
(define-syntax-rule (m id)
 (let ([id "inner"])
   x))
(m x)

I want to point this out now because I saw racket/racket#4929, which proposes to add something new to the syntax-local- zoo to support the implementation of Rhombus let. I'm a little skeptical of the current implementation strategy for let given that it gets this use-site binder hygiene wrong, and it feels like it'd be unfortunate to expose more low level syntax-local- operations that could point users towards implementations of scoping structures that don't get hygiene right.

In contrast, an implementation of let using definition contexts and local-expand should be able to avoid this problem because one of the things definition contexts encapsulate is a set of local use-site scopes. I don't know enough about Rhombus to know what other implementation constraints there are, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions