3 ms·
Besides Ruby-like syntax how does it differ from parametrized modules? From his example: = Reia: class Foo def initialize(value) @value = value
by deno 16y ago
Besides Ruby-like syntax how does it differ from parametrized modules?
From his example:
= Reia:
class Foo
def initialize(value)
@value = value
end
def value
@value
end
end
= Erlang:
-module(foo, [Value]).
value() -> Value.
And it's actually prettier.
Can you do some crazy pattern matching and type overloading like with Scala? Or is it just syntactic sugar for parametrized modules?
- mononcqc 16y agoMy quick guess would be 1. the initialize function allows you to encapsulate modifications to data when it is received. A parametrized module only takes a variable, so any modification done to the parameters needs to be done outside the module (Mod:new(F(Arg))). 2. Semantically speaking, parametrized modules are NOT classes/objects. They're meant as a syntactic shortcut to carry state and a module name as a single variable when calling it and writing the module itself. What I mean is that Mod:Fun(Arg) now becomes Mod:Fun(), and Arg is hidden within Mod (The current implementation is {ModuleName, Arg}:Fun()). This use is rarely necessary and often seen as bad form by many Erlang regulars (myself included), mostly because it introduce new [superfluous] ways to do existing things in a language where its small core is appreciated. Also functional programmers getting mad at OO programmers trying to get their way in a language that was not meant for that.
- bascule 16y agoParameterized modules don't have constructors. That doesn't matter in a trivial case, but it does when you want some complex state set-up which you don't want to repeat every single time you "instantiate" a parameterized module? Also, Reia has inheritance. Parameterized modules don't.
- deno 16y agoThey certainly do with -extends(). As for constructors… there's probably way around that too. Point is Reia's OO-revolution doesn't introduce any fundamental changes besides syntax.
- bascule 16y ago-extend() is another half-assed solution. It's closer to mix-ins than inheritance. Object orientation in Reia is baked into the core language itself. Like Ruby, all of its core types are objects. In Perl and Erlang they are not. Reia factors the core language types into objects, instead of amalgamations of the core types with arbitrary and poorly factored functions which act on them.