Summary

Expansion of internal definitions ignores import status/redefinition of `define` et al.

Metadata

Description

Forms starting with define, define-values and define-syntax are expanded as internal definitions in let and lambda bodies regardless of whether those identifiers have been imported or redefined to some other transformer.

With redefinition:

 (define-syntax define
   (syntax-rules ()
     ((_ . a) (list . a))))
 
 ;; Works, gives (1 2 3).
 (define 1 2 3)
 
 ;; Works, prints (1 2 3), since the define isn't treated
 ;; as an internal definition.
 (let ()
   (display (define 1 2 3)))
 
 ;; Fails, errors since the define is treated as an internal 
 ;; definition when it should instead return a list.
 (let ()
   (define 1 2 3))

Without having been imported:

 ;; Works, errors due to define being unbound.
 (module foo ()
   (import (except scheme define))
   (define a 1))
 
 ;; Fails, should error due to define being unbound but doesn't.
 (module foo ()
   (import (except scheme define))
   (let () (define a 1)))

The same applies for define-values and define-syntax.

Bindings introduced by let, let-syntax and friends are handled correctly.

Changes and comments

[2016-08-25 21:34:54 UTC] sjamaan set difficulty to hard

[2023-11-06 23:49:23 UTC] felix changed milestone from someday to 6.0.0

[2023-11-08 11:56:05 UTC] felix changed milestone from 6.0.0 to 5.4

[2023-11-10 14:58:34 UTC] sjamaan changed status from new to closed

[2023-11-10 14:58:34 UTC] sjamaan set resolution to fixed

[2023-11-10 14:58:34 UTC] sjamaan wrote:

Fixed with 75c0461c8b541a3b03e337e7546ce3b0ea4e6931