Structs (was RE: Record selectors)

Vlad Dumitrescu (EAW) <>
Wed Jan 15 09:18:38 CET 2003

Hi Chris,

>Forgive me, but is Erlang really so object-shy that encapsulation is
>something that we feel we can afford to avoid simply because "they" have
>turned it into a meaningless buzzword?

I am by no means an Erlang guru, but I was once for not so long ago just as puzzled by the same question. Now I got used to the "hard core" Erlang way and it works just as well.

To make sure we are referring to the same thing: encapsulation is one issue, having support from the compiler & run-time for a nice syntax and better efficiency is another. In fact, in Erlang one can use encapsulation on two levels: by writing wrapper functions and by using a server process. One can also use both (even if I remember someone arguing that it is better to write "Pid ! Msg" than encapsulate it in a function call, because the former does not hide that there is a process doing the work).

The latter issue is at stake, together with the expressed need to have some kind of type checking. If there is a way to get the best of both worlds without paying too much for it, then it will be found and implemented. 

As for objects, I think processes can implement the underlying concept better than for example C++ objects. Hey, one could even think of compiling today's records (or tomorrow's mutable coagulators :-) into processes! The big minus is efficiency, but the coolness factor might be bigger :-)

best regards,

More information about the erlang-questions mailing list