当前位置:网站首页>The writing style of the construction and interpretation of the mini LISP interpreter
The writing style of the construction and interpretation of the mini LISP interpreter
2022-06-21 05:28:00 【ccat】
Today, I saw some readers complain that my book is to print out the source code for sale . I can understand this feeling , But in fact, this writing style is the result of repeated attempts , Instead of being lazy . The source code attached to the book , A lot of them use Scala To annotate Java . For example, yesterday my good friend asked me Java edition Env Type of get Why does the method use a try catch,
public Object get(String name) throws ParserException {
try {
return findIn(name);
} catch (ParserException notfound) {
return findOut(name);
}
}
This is actually on the next page Scala The version is very clean
def get(name: String): Try[Any] = {
findIn(name).orElse(findUp(name))
}.Java The implementation of the , Just to get as close as possible Scala Of Try[T] , This is closer to a getOrElse Not error handling . This contrast of different languages , In the process of my development and writing , It brings a lot of inspiration and fun , It is also the experience I want to share with readers .
I read alone , Sometimes not patient enough , Will often skip the text and gnaw the code , This also affects writing . The future is also a place for improvement .
When sorting out this code , My idea is more like the process of writing mathematical problems . A caption 、 Illustrations can certainly help understand , I will try to add in the future version , But in the end , Programming problems , It is still to be solved by writing code . These codes are repeatedly modified to the current state , Than github Is easier to read . I also removed some engineering code as much as possible . Of course , Generally speaking , Same function ,Java The implementation of is usually better than Scala More verbose . But there are some interesting details to show . and Scala Code for , If you remove the explicit type definitions of variables and functions , It must be much more beautiful , But if the reader follows that code , You will encounter many compiler warnings and even type derivation errors . This point , I actually hope that in the future scala Can be like haskell So the dimension type , After all scala 3 Even indentation syntax can be implemented , The attitude of developers is still very open .Haskell Style annotation types , Combining indentation Syntax , It will be very helpful for typesetting, printing and reading .
There are also some implementations in the book , At the same time Scala 2 and Scala 3 Version of , This is because Scala 3 Of FP The grammar has changed a lot , Closer to the Haskell The system of . By showing Scala 3 Version of , Can better explain why these designs are so .
The other is if the reader can read directly github in JISP and SISP Code for , Of course, it's also very happy for me . But the code is missing some information , Mainly Commit Records do not necessarily represent correctness 、 Clear build process , There are a lot of debug、parsec Upgrade and think 、 test 、 Trial and error and writing correction . In the future, I will try to build a clear process , Teaching Library with chapter division . Not yet , Because these three years Jaskell The library is still developing rapidly , I have basically made some revisions every month in recent years . Teaching demonstrations and documentation , It can only be solved by investing a lot of work , There is no shortcut. .
Last , Thank you for your comments and suggestions , You are my driving force .
边栏推荐
- 常见的存储类型
- [punch in] subarray sum is k
- 工厂方法模式(Factory Pattern)
- Mac MAMP Pro installation PHP extension method
- Randomly create circular, triangular or rectangular objects, store them in the array, and calculate the area and perimeter of each shape
- 迎接创客教育+互联网的黄金时代
- 关于PHP签名中的容易犯错问题记录
- Mac NAMP Pro comes with MySQL 5.7 setup SQL_ Model remove only_ FULL_ GROUP_ Invalid by may be caused by:,
- 解读复合型新工科机器人教育模式
- 5. Implementation of watch method
猜你喜欢

Physical principle of space design in maker Education

OracleLinux6.5图形化安装Oracle11g

七大设计原则

Use of TestNG framework (I): idea installation TestNG environment

Ue4/5 impactor on begin overlap and on end overlap trigger simultaneously for resolution

Interview questions_ V1.0

How to ensure database and cache double write consistency?

Day code 300 lines learning notes day 16

Sentinel熔断限流真的太丝滑了

LaTeX给表格的一整行加删除线(横线)
随机推荐
83.(cesium篇)cesium示例如何运行
解读复合型新工科机器人教育模式
The Mac OS MAMP installs redis with an error/ common. h:12:10: fatal error: ‘zend_ smart_ str.h‘ file not found
House sales and leasing system based on ssh+mysql
launcher切页动画
Global and Chinese markets for implantable heart devices 2022-2028: Research Report on technology, participants, trends, market size and share
还不了解最新版Kubernetes?一节公开课解决你所有疑问
Reflective
Steam education subject integrates the intelligent scene of AR
[url parameter] convert the object JSON to "URL parameter"? param1=...& param2... Form of
renren-fast启动提示 process.env.NODE_ENV
VMware新建OracleLinux6.5虚拟机
无代码探索者大会,轻流邀您共同探讨数字化转型实践之路
C语言:随机输入每位同学中每门学科的成绩,要求每位同学的所有学科平均分从低到高排序求出每位同学的平均成绩后,再进行判断该同学的平均成绩是否达到及格。
launcher切頁動畫
A comprehensive interpretation of the gold content, detailed introduction and test strategy of CKA certification
IDEA Debug出现:Skipped breakpoint at because it happened inside debugger evaluation
【毕业季】九年程序猿有话说
Global and Chinese markets of tunable lasers 2022-2028: Research Report on technology, participants, trends, market size and share
MyBaits-plus