Transcript Erlang

LOGO
Erlang
11 ACM 王浩然
Company Logo
concurrency
in real world
in computer
Company Logo
concurrency
Here, we encounter a quz.
Company Logo
concurrency
x = x+n.
 1.mov ax,[bp +x]
 2.mov bx,n
 3.add ax,bx
 4.mov[bp+x],ax
multi-process share the registers.
Company Logo
concurrency
If there is a Way or PL supporting
this?
Yes!
COP, Erlang.
Company Logo
concurrency
Let's change a model.
The relation of the multi-process to a
computer
staff to a community
Company Logo
concurrency
Properties:
• Independent
• No sharing memory
• Sending message
Company Logo
Concurrency Primitives
Pid = Spawn(fun)
Pid ! Message
receive ... end
Receive Pattern
Company Logo
Concurrency
A simple model
Client & Server
Sending& Receiving
Company Logo
rect
Company Logo
clock
What if never receive a message?
waiting forever?
after
Company Logo
Other features
Variable!
• no type declaration.
Company Logo
Variable
A strange fact
Company Logo
Variable
What on earth is going on here??
Explain
• X not a variable
• = is not an assignment operator
Why is this?
Company Logo
Other features
 "=", Pattern Matching Operator
can apply on storing compound data
overload the function:
Company Logo
Other features
Functional Programming
• function: first class, same as other data types.
Company Logo
Summary
Not totally understanding
Still Missed Many Advantage
LOGO