Hello everyone,
Elixir v0.10 is coming out soon, we have some improvements planned for pretty printing and we should be good to go. That said, I recommend everyone to give Elixir master a try. If you are on homebrew (Mac OS X), this is just a matter of:
brew unlink elixir
brew install elixir --HEAD
If you are not on homebrew, we have instructions for compiling from master in
our getting started. Don't forget to
fully recompile your projects and their dependencies once you move to master.
The CHANGELOG lists our new features and our release announcement will go into more details on a couple of those. For this e-mail, I will go over details about the backwards incompatible changes to make the upgrade process easier.
1. Calling `Module.register_attribute/3` no longer automatically changes it to persisted or accumulated
The first thing you should do when upgrading to master is to search your project for calls to "Module.register_attribute". In previous versions, calling:
Module.register_attribute __MODULE__, :some_attribute
Automatically changed the attribute to persist and accumulate. Now, those arguments need to be explicitly given:
Module.register_attribute __MODULE__, :some_attribute, persist: true, accumulate: true
The choice for making those explicit is because many people were accidentally making their attributes persisted when they just wanted to accumulate it.
2. First element of a record via `defrecordp` is now the `defrecordp` name and no longer the current atom
The second change you should do is to search your project for occurrences of defrecordp. Previously, defrecordp returned the module name as the first element of the tuple:
defmodule User do
defrecordp :user, [:name, :age]
def new do
user()
end
end
User.new #=> { User, nil, nil }
In master, it is no longer the case, the first element is the record name:
User.new #=> { :user, nil, nil }
This is closer to how both Erlang records and defrecord behaves.
If you want to keep the previous behaviour, you can simply pass the module name as argument:
defrecordp :user, User, [:name, :age]
3. The `Binary.Inspect` protocol has been renamed to `Inspect`
One of the main features in v0.10 is support for pretty printing. The semantics of the Inspect protocol changed as of now an implementation for Inspect must return an algebra document and we have changed the protocol name to honor those new semantics. Luckily, a regular string is an algebra document, so If you are in a worry, you will likely be able to simply rename your implementations of the protocol from Binary.Inspect to Inspect and call it a day. However, if you want to use the pretty printing conveniences, we recommend you to start with reading the
docs for Inspect.
4. Tighter grammar rules
In previous releases Elixir was very flexible with omitting parenthesis. The downside of that is that your code have more ambiguity, here is an example:
Will the code above return [1, true, 3] or fail to compile because there is no function called is_atom that receives two arguments? That said, we have tightened the grammar rules a bit and the code above (and similar) will now fail to compile. Adding explicit parenthesis fixes it:
5. Custom parsers no longer supported in URI
Previously the URI module supported custom parsers. This functionality has been removed in favor of simplicity, so if you were registering new schemas with custom ports, this should now be done via URI.default_port/2.
6. Enjoy!
Those are the braking changes for this release. There has been a couple of deprecations too, but you will get warning for those. Everything else should just work™.
José Valim
Skype: jv.ptec
Founder and Lead Developer