josevalim

josevalim

Creator of Elixir

Call to library authors: define "Nutrition facts" for your meta-programming

One common concern about using Elixir libraries is that use SomeModule does not make clear how it impacts the caller. While the goal of use is precisely to provide a common extension point, and most of the time those changes are minor, it is impossible to know what it does without reading the source code.

For this reason, from Elixir v1.15, we are recommending libraries to include a summary alongside each module, typically within the first section of its @moduledoc, that succinctly explains the impact of using said modules. In this pull request, we have added this note to all use XYZ modules in stdlib, like this:

> #### `use GenServer` {: .info}
>
> When you `use GenServer`, the GenServer module will
> set `@behaviour GenServer` and define a `child_spec/1`
> function, so your module can be used as a child
> in a supervision tree.

Which will be rendered like this (see block at the bottom):

Think of it as “Nutrition facts” for meta-programming. If you are a library author and your modules can be used, please consider doing the same. :slight_smile:

Most Liked

sodapopcan

sodapopcan

With careful consideration, use beneficially cleans up a lot of noise and I’m glad it exists.

(•_•) even if it is a bit
( •_•)>⌐■-■
(⌐■_■) overused

Sorry, I couldn’t resist. I’ll see myself out.

33
Post #6
kip

kip

ex_cldr Core Team

Good idea. I’ll update the ex_cldr libs over the next week or so.

Update: added to the ex_cldr README and the Cldr module and published to hex.pm.

18
Post #3
fceruti

fceruti

On a somewhat related note, a cool feature available on neovim using elixir-tools, is the expand macro:

162372669-4782baba-1889-4145-8a4f-e3bf13a6450d

Nicd

Nicd

This is where libraries that don’t use use win, nothing to document! :grin:

17
Post #4
hst337

hst337

https://hexdocs.pm/pathex/Pathex.html#__using__/1

Check this out. I’ve written this information in three different places already.

Where Next?

Popular in Notices Top

josevalim
Hello everyone, We had a discussion on elixir-lang-core about deprecating the use of ‘single quotes’ in Elixir for charlists. The use o...
New
josevalim
Hello everyone, Last year we have announced GenStage and then developed Flow. Our initial plan was to make GenStage part of Elixir. Tha...
New
josevalim
Hi everyone, With the v1.7 release, we have received reports of some dependencies no longer working properly on the new release. Develo...
New
ericmj
We are moving the builds for precompiled versions of Elixir, Erlang/OTP, and Hex itself. These are currently hosted on https://repo.hex.p...
New
josevalim
One common concern about using Elixir libraries is that use SomeModule does not make clear how it impacts the caller. While the goal of u...
New
josevalim
Hi everyone, I have updated Elixir’s wiki page on IDE/Editor support and I am now linking to it from the website. If you know of other ...
New
josevalim
Hi everyone, Elixir v1.19.0-rc.0 included a deprecation of the struct update syntax. However, we will ship with a different warning on E...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement