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.
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.
Erlang采用基于进程的并发模型,通过轻量级进程及异步消息传递实现高效并发处理。变量使用单次赋值,配合模式匹配语法,简化程序编写。Erlang不支持共享内存,进程间交互仅通过异步消息传递完成。
1486

被折叠的 条评论
为什么被折叠?



