Deferred Substitution

在执行出现with时,利用“substitution”,每次with的出现,它都绕着整个body置换。这一方式是由F1WAE到env再到list-of-FunDef为止,然后再到substitution列表中,以env的形式进行。

In Case of WAE

DefrdSub

(define-type DefrdSub
[mtSub]
[aSub (name symbol?)
(value number?)
(rest DefrdSub?)])

lookup : symbol DefrdSub -> number

(define (lookup name ds)
(type-case DefrdSub ds
[mtSub () (error 'lookup "free variable")]
[aSub (x val rest) (if (symbol=? x name)
val
(lookup name rest))]))

interp : WAE -> number 换成 WAE DefrdSub -> number

(define (interp wae ds)
(type-case WAE wae
[num (n) n]
[add (l r) (+ (interp l ds) (interp r ds))]
[sub (l r) (- (interp l ds) (interp r ds))]
[with (x i b) (interp b (aSub x (interp i ds) ds))]
[id (s) (lookup s ds)]))

In Case of F1WAE

不经思考,会造成如下后果:

{deffun {f x} {+ y x}}
(interp (parse '{with {y 2} {f 10}})), env:[]
->(interp (parse '{f 10})), env:[y=2]
->(interp (parse '{+ y x})), env:[x=10 y=2]
->12 wrong!
更准确地说,这是static scope不适合的体现。

interp : F1WAE list-of-FunDef DefrdSub -> number

(define (interp f1wae fundefs ds)
(type-case F1WAE f1wae
...
[app (ftn arg)
(local [(define a-fundef (lookup-fundef ftn fundefs))])
(interp (fundef-body a-fundef)
fundefs
(aSub (fundef-arg-name a-fundef)
(interp arg fundefs ds)
(mtSub)))]))
在进行“function call”时,将DefrdSub重新装入env,使其成为“arg substitution”。(local设计)

Programming Languages_04 Deferred Substitution的更多相关文章

  1. PLAI那些事_07 FAE with Deferred Substitution

    FAE-parse : 一成不变 FAE-Value : interp的最终转让值 ;;numV: value ;;closureV: param-FAE(或value,或function) pair ...

  2. Linux Kernel Programming - Time,Delays,and Deferred Work

    Measuring Time Lapses The counter and the utility functions to read it live in <linux/jiffies.h&g ...

  3. 10 The Go Programming Language Specification go语言规范 重点

    The Go Programming Language Specification go语言规范 Version of May 9, 2018 Introduction 介绍 Notation 符号 ...

  4. Programming Entity Framework 翻译(1)-目录

    1. Introducing the ADO.NET Entity Framework ado.net entity framework 介绍 1 The Entity Relationship Mo ...

  5. apple 官方文档 Push Notification Programming

    iOS Developer LibraryDeveloper Search Local and Push Notification Programming Guide PDF Table of Con ...

  6. javascript --- jQuery --- Deferred对象

    javascript --- jQuery --- Deferred对象 javascript的函数式编程是多么引人入胜,jQuery使代码尽可能的精简,intelligent! defer - 必应 ...

  7. Important Programming Concepts (Even on Embedded Systems) Part V: State Machines

    Earlier articles in this series: Part I: Idempotence Part II: Immutability Part III: Volatility Part ...

  8. The Go Programming Language. Notes.

    Contents Tutorial Hello, World Command-Line Arguments Finding Duplicate Lines A Web Server Loose End ...

  9. Promise & Deferred Objects in JavaScript Pt.2: in Practice

    原文:http://blog.mediumequalsmessage.com/promise-deferred-objects-in-javascript-pt2-practical-use Intr ...

随机推荐

  1. matplotlib AffineBase, Affine2DBase, Affine2D

    2020-04-10 09:02:59 --Edit by yangray 仿射变换矩阵参考资料-->https://blog.csdn.net/robert_chen1988/article/ ...

  2. Python Requests-学习笔记(10)-会话对象

    会话对象让你能够跨请求保持某些参数.它也会在同一个Session实例发出的所有请求之间保持cookies. 会话对象具有主要的Requests API的所有方法. 我们来跨请求保持一些cookies: ...

  3. CSS躬行记(6)——滤镜

    滤镜(filter)可改造元素的视觉呈现,CSS内置的滤镜有10种,通过SVG文件还能自定义滤镜. 一.调色滤镜 调色滤镜可控制元素的模糊.颜色.亮度等变化,并且多个滤镜可组合在一起使用.这些滤镜大部 ...

  4. 代码质量管理 SonarQube 系列之 安装

    简介 SonarQube 是一个开源的代码质量管理系统. 功能介绍: 15种语言的静态代码分析 Java.JavaScript.C#.TypeScript.Kotlin.Ruby.Go.Scala.F ...

  5. 给我Python几十行代码,我还你一个微信聊天助手

    前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: 故事胶片 PS:如有需要Python学习资料的小伙伴可以加点击下方链 ...

  6. 掉了10根头发都无法解决的数学题,python帮你完美解答

    本来这个周末过得开开心心,结果为了解一道数学题薅掉了一把头发...整整10根! 而且还是一道小学数学题!!! 到底是什么题呢?大家看看吧 这不就是一道逻辑题嘛! 先假如丁错,则甲乙丙对,此时最小的ab ...

  7. Atcoder E - Crested Ibis vs Monster、

    一看到题目就觉得是一个背包问题,但是不知道怎么写. 题解:直接求背包容量为2*h时所需要的花费.然后h~2h都是满足条件的,去最小值即可. code: #include<bits/stdc++. ...

  8. Laravel joinSub 子查询的写法

    $subQuery = $model::query() ->from('table1 as a') ->getQuery(); $query = $model::query() -> ...

  9. 2016NOIP普及组T2回文日期

    回文日期 分类:枚举,函数 [题目描述] 日常生活中,通过年.月.日这三个要素可以表示出一个唯一确定的日期. 牛牛习惯用8位数字表示一个日期,其中,前4位代表年份,接下来2位代表月份,最后2位代表日期 ...

  10. [转]ThinkCMF框架任意内容包含漏洞分析复现

    0x00 简介 ThinkCMF是一款基于PHP+MYSQL开发的中文内容管理框架,底层采用ThinkPHP3.2.3构建.ThinkCMF提出灵活的应用机制,框架自身提供基础的管理功能,而开发者可以 ...