[erlang-questions] OO programming style in Erlang?
Mon Jan 22 12:44:01 CET 2007
Ladislav Lenart wrote:
> I have an OO experience and I like the basic ideas of encapsulation
> and polymorphism but can not find a way how to materialize these in
> my Erlang programs.
> For example, there are dict and orddict modules which have compatible
> (polymorphic) interfaces but differ in their implementations. This is
> essentially good, but when I actually use one of these modules, my
> code will look like
> But this is bad because when I later decide to change (my) implementation
> I actually have to go through my code and replace orddict with dict. So
> this is not a polymorphism I am looking for.
One way of avoiding this problem is the one we follow in various modules
of the HiPE compiler. We use the preprocessor as follows:
and then write all calls as:
Not really deep, but it does what we want.
More information about the erlang-questions