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

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

gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43757 214
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54120 245
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement