Scheme Language
from SICP:
If Lisp is not a mainstream language, why are we using it as the framework for our discussion of programming? Because the language possesses unique features that make it an excellent medium for studying important programming constructs and data structures and for relating them to the linguistic features that support them. The most significant of these features is the fact that Lisp descriptions of processes, called procedures, can themselves be represented and manipulated as Lisp data. The importance of this is that there are powerful program-design techniques that rely on the ability to blur the traditional distinction between ``passive data and ``active processes. As we shall discover, Lisp's flexibility in handling procedures as data makes it one of the most convenient languages in existence for exploring these techniques. The ability to represent procedures as data also makes Lisp an excellent language for writing programs that must manipulate other programs as data, such as the interpreters and compilers that support computer languages. Above and beyond these considerations, programming in Lisp is great fun.
I think it is time to move on. So I decide to study this "not a mainstream language".
I know it is hard to study and understand. I really do. But it is so funny to do such a job.
ok , now I will show you some thing new .
the code goes here:
(define a-plus-abs-b
(lambda (a b)
((if (>= b 0) + -) a b)))
the amazing thing is that you can choose the operator at runtime!
that is so powerful and so simple. In the other language such as c/c++ , it will take a complex code to get this.
LISP
- Lambda运算
- Lisp Processing
- 没有语法
Scheme
- LISP
- Continuation
特征
- 高阶函数
- 匿名函数
- 直接在抽象语法上工作
- 简单一致的数据类型
- 尾递归:代码不会膨胀
明显的好处,就是程序员不用像在其它程序语言里面那样,去特别记忆各种不同的语法结构以及这些结构之间进行组合所要考虑的优先级的安排、结合律的安排、以及语法变形的安排。这些问题统统一去不复返。sexp 的第一个单词决定了 sexp 的意义,剩下的单词都是参数。记住这一条规则足够了。
明显的坏处,就是大量的括号,以及括号的深层嵌套,使得括号匹配成了件让人畏惧的事。这是为什么 Lisp 程序员几乎无一例外的喜欢 Emacs编辑器的原因。因为在 Emacs 的帮助下,括号匹配对于 Lisp 程序员来说,就不再是一头拦路猛虎。关于 Emacs 和 Lisp 以及Scheme 的协调合作,我们在以后的文章中会详细的讲到
Comments (0)
You don't have permission to comment on this page.