Cultivate's Elixir Posts

blog-posts

#1

We have a few on our blog: https://cultivatehq.com/posts/tag/elixir/ . Some (especially the Phoenix/Elm ones) are a little out of date.


#2

Ok, so trying to follow @AstonJ’s instructions on posting about blogs and here I am.

I mainly wanted to say that I just published something on nested modules, https://cultivatehq.com/posts/elixir-nested-modules-imports-and-aliases/ because I just discovered that aliases and imports from outer modules are also imported and aliased in the nested module.

I couldn’t find the behaviour documented anywhere. Did I just miss it?

Also wondering if this is deliberate or a side effect of how things are compiled.


#3

I couldn’t find it either - also had a quick look in some of my books and not mentioned there either :101:


#4

This is “documented” when we say that alias, import and require are lexical. It means they do not care about functions, modules, conditionals, cases. At the moment they are defined, everything below the declaration in the same code branch will have the same aliases, imports, etc. So this is pretty much deliberate behaviour. :slight_smile:

Of course, saying that the documentation is in the word “lexical” is a bit cryptic, so improvements to the Elixir documentation with examples are very welcome. Thank you! :heart:


#5

Ah, here: https://hexdocs.pm/elixir/Kernel.SpecialForms.html#alias/2-lexical-scope

(Looks up lexical scope)

Thanks @josevalim. Makes sense. I’ll amend the post and maybe think about a documentation PR.


#6

We’ve now launched a companion blog, Bytesize, for small bites (bytes - geddit?) of technical information: “today I learnt” or “just did this cool thing” type of posts. There’s a few Elixir posts on it already:


#7

I love this sort of thing, thank you for posting about it.