So far, my tiny object system in Elixir has been stowing all methods directly in instances. Chapter 5 of FPOO directs me to move instance methods out into a “class” of some kind.

First off, there’s no more
new_point . In its place, a simple keyword list defining attributes of the class. The instance variables are no longer hard-coded in the keyword list. Instead, there is a new
add_instance_values callback that plays the role of an initializer method.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

def point()do

[

__own_symbol__::point,

__instance_methods__:[

class:&get(&1,:__class_symbol__),

add_instance_values:fn(this,x,y)->

this|>merge([x:x,y:y])

end,

shift:fn(this,xinc,yinc)->

make(point,[get(this,:x)+xinc,get(this,:y)+yinc])

end

]

]

end

Next up, a new
make function that can use this style of class definition.