Quick curiosity…

In Erlang, single assignment is like algebra…

When I went to school, my math teacher said, “If there’s an X in several different parts in the same equation, then all the Xs mean the same thing.” That’s how we can solve equations: if we know that X+Y=10 and X-Y=2, then X will be 6 and Y will be 4 in both equations.

But when I learned my first programming language, we were shown stuff like this:
X = X + 1

Everyone protested, saying “you can’t do that!”. But the teacher said we were wrong, and we had to unlearn what we learned in math class. X isn’t a math variable: it’s like a pigeon hole/little box…

In Erlang, variables are just like they are in math. When you associate a value with a variable, you’re making an assertion – a statement of fact. This variable has that value. And that’s that.

In “Armstrong, Joe; Programming Erlang; The Pragmatic Programmers; 2007

3 thoughts on “Quick curiosity…

  1. nao sabia que havia portugueses interessados em Erlang 🙂

    eh uma linguagem que vale apena e nos dias que correm tem-se demonstrado ainda mais importante devido a sua escalabilidade brutal!

    here here for Erlang! 😉

  2. Edson,

    Depois de bounded, sim, não podes alterar. Não deixa de ser uma variavel. Foi o primeiro conceito de variavel q aprendeste, la no 6º ou 7º ano.. 😀


    O tarpipe.com é um projecto feito por portugueses em Erlang. O SAPO tb usa Erlang (messenger). E concerteza que haverá muitos mais escondidos por aí fora.. 🙂

Comments are closed.