erlang book 零星摘要

Erlang采用基于进程的并发模型,通过轻量级进程及异步消息传递实现高效并发处理。变量使用单次赋值,配合模式匹配语法,简化程序编写。Erlang不支持共享内存,进程间交互仅通过异步消息传递完成。
Erlang has a process-based model of concurrency with asynchronous message passing.The concurrency mechanisms in Erlang are lightweight, i.e. processes require little memory, and creating and deleting processes and message passing require little computational effort.

Erlang has no shared memory. All interaction between processes is by asynchronous message passing.

Our goal was to produce a small, simple and ecient language suitable for programming robust large-scale concurrent industrial applications.

The use of a pattern matching syntax, and the `single assignment' property of Erlang variables, leads to clear, short and reliable programs.

The values of Erlang data types can be stored in variables. Variables always start with an upper-case letter.

The match primitive can be used to unpack items from complex data structures.

The special variable underscore (written `_') is the anonymous or don't care variable. It is used as a place holder where the syntax requires a variable, but the value of the variable is of no interest.

While we can think of send as sending a message and receive as receiving a
message, a more accurate description would be to say that send sends a message
to the mailbox of a process and that receive tries to remove a message from the
mailbox of the current process.

Atoms are constants with names;Atoms are used to enhance the legibility of programs.

Pattern matching provides the basic mechanism by which values become assigned
to variables.

Pattern matching occurs:
when evaluating an expression of the form Lhs = Rhs
when calling a function
when matching a pattern in a case or receive primitive.


Many people think that the use of destructive assignment leads to unclear programs which are dicult to understand, and invites obscure errors.


The expression list(H) which comes between the keyword when and the `->' arrow is called a guard. The body of the function is evaluated if the patterns in the function head match and if the guard tests succeed.

Each function is built from a number of clauses. The clauses are separated by
semicolons `;'. Each individual clause consists of a clause head, an optional guard and a body.

A guard can be a simple test or a sequence of simple tests separated by commas.

Guards can be viewed as an extension of pattern
matching. User-dened functions cannot be used in guards.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值