July 1st Wednesday (七月 一日 水曜日)

本文介绍了Scheme语言中命名空间的概念及其工作原理。命名空间将符号映射到不同阶段级别的三种可能绑定:特定模块绑定、顶级转换器绑定和顶级变量。此外,文章还探讨了命名空间与环境的区别以及在代码扩展和链接过程中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Namespace in mzscheme

  For expansion purposes, a namespace maps each symbol in each phase level to one of three possible bindings:

*a particular module binding from a particular module

*a top-level transformer binding named by the symbol

*a top-level variable named by the symbol

  A namespace is purely a top-level entity, not to be confused with an environment. In particular, a namespace does not encapsulate
the full environment of an expression inside local-binding forms.

  If an identifier is bound to syntax or to an import, then defining the identifier as a variable shadows the syntax or import in
future uses of the environment. Similarly, if an identifier is bound to a top-level variable, then binding the identifier to syntax
or an import shadows the variable; the variable's value remains unchanged, however, and may be accessible through previously evaluated
expressions.

  After a namespace is created, module instances from existing namespaces can be attached to the new namespace. In terms of the evaluation
model, top-level variables from different namespaces essentially correspond to definitions with different prefixes. Furthermore, the first
step in evaluating any compiled expression is to link its top-level variable and module-level variable references to specific variables in
the namespace.

  At all times during evaluation, some namespace is designated as the current namespace. The current namespace has no particular relationship,
however, with the namespace that was used to expand the code that is executing, or with the namespace that was used to link the compiled form
of the currently evaluating code. In particular, changing the current namespace during evaluation does not change the variables to which executing
expressions refer. The current namespace only determines the behavior of reflective operations to expand code and to start evaluating expanded/compiled
code.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值