It’s quite common to have functions in a module take the data abstraction/state of that module as a first argument. Do you call that argument something special or just go by naming it on a case by case basis?
defmodule Garden do
def sow(garden, seed) do ...
def harvest(garden, plant) do ...
Using this or self feels kind of OOP and there isn’t really a this concept, so perhaps use the snake cased module name like in the example above? I just want to not have to make a decision about this every time I write a function
Also, is there any documentation on ‘ideomatic elixir’ that collect stuff like this?
Just look at the Elixir source code to find out.
I absolutely don’t mean in this in any harsh way or anything, I really think it’s that simple. If the Elixir standard library isn’t ideomatic I don’t know what else would be.
For you particular question, if you look or example at the
Map module, you can see that all the functions that accept a
map as the first argument simply call it
map. If you look at the
HashSet module, the first argument is called
set, so I think your guess was pretty accurate
self is already a function in
Kernel that returns the PID of the process where
self is called from: