Suzanne Soy <racket@suzanne.soy>
debug-scopes))
When using named scopes—for example, via debug-scopes/named-scopes/override—a named scope is often used instead of the macro scope flipped by syntax-local-introduce . If +scopes is called within that context, it also annotates the whole expression with the named scope which acts as a replacement for the macro scope, using the notation (expression…)ˢˡⁱ⁼⁴⁺ᵘˢᵉ⁼¹²⁽ⁿᵃᵐᵉᵈ⁼⁵⁾ (which would indicate that the original macro scope was 4, the use-site-scope is 12, and the named macro scope is 5).
debug-scopesdebug-scopes/named-scopes))
syn?))(current-trace-print-args(current-trace-print-results>(let "(let⁰˙˙³ ((x⁰˙˙³ 5)) (let⁰˙˙³ ((y⁰˙˙³ 120)) y⁰˙˙³))ˢˡⁱ⁼²⁺ᵘˢᵉ⁼³")
<"((lambda⁰˙˙¹ (x⁰˙˙³) (let⁰˙˙³ ((y⁰˙˙³ 120)) y⁰˙˙³)) 5)ˢˡⁱ⁼²⁺ᵘˢᵉ⁼³"
>(let "(let⁰˙˙⁶⁻² ((y⁰˙˙⁶⁻² 120)) y⁰˙˙⁶⁻²)ˢˡⁱ⁼⁶⁺ᵘˢᵉ⁼")
<"((lambda⁰˙˙¹ (y⁰˙˙⁶⁻²) y⁰˙˙⁶⁻²) 120)ˢˡⁱ⁼⁶⁺ᵘˢᵉ⁼"
120
procedure
( print-full-scopes [reset?])→void?
This allows to get some extended information about the scopes in a summary table by calling print-full-scopes , while still getting short and readable display of syntax objects with +scopes .
After running (print-full-scopes ), if reset? is true, then the scope counter is reset (and +scopes therefore starts numbering scopes starting from 0 again).
Module scopes bear are annotated by Racket with the name of the module. As of December 2016, other scopes like macro scopesBoth the ones implicitly created when a macro is called, and the ones explicitly created via make-syntax-introducer are concerned by this or use-site scopes lack any form of annotation or naming.
procedure
( make-named-scope name)
procedure
( make-module-like-named-scope name)
This module overrides define-syntax and syntax-local-introduce to automatically use a named macro scope. The use-site scope is not affected for now, as the original unnamed use-site scope from Racket benefits from special cooperation from definition contexts, which would be hard to achieve with the hack currently used to implement named scopes.
syntax
( define-syntax (namestx-arg). body)
Note that this change only affects the scopes introduced by the overriden version of syntax-local-introduce , not the original syntax-local-introduce .
This means that if the macro calls a function defined in another file which uses the non-overidden version of syntax-local-introduce , both the original unnamed scope and the named scope may accidentally appear in the result. Macros defined using the overridden syntax-local-introduce should therefore take special care to always use the overridden version of syntax-local-introduce .
The use-site scope is not affected for now, as the original unnamed use-site scope from Racket benefits from special cooperation from definition contexts, which would be hard to achieve with the hack currently used to implement named scopes.
procedure
( syntax-local-introduce stx)→syntax?
stx:syntax?