-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
This is a list of upcoming deprecations coming to Elixir. Most of those are anti-patterns anyway, which we kept in the language to avoid churn, but the addition of the type system will likely accelerate their deprecations anyway.
-
Regex.replace/3- this function allows a function of any arity to be given as argument, based on the amount of regex matches. Instead, this should have been written as a single function that receives a list of matches. We will need to address this by, most likely, introducing a new function, such asreplace_indexesandreplace_binaries. -
File.stat/1- this function changes the return type based on an option which is, generally speaking, an anti-pattern. While the type system can model these return types using multiple clauses, it adds general complexity. Furthermore, I'd say this function has the wrong default, it should have defaulted to returning unix timestamps instead. The idea is to deprecateFile.stat/1and always force thetime: :unixoption to be given. -
Node.spawnandProcess.spawn- Deprecate passing the:monitoroption to bothspawnandspawn_link. Add option support tospawn_monitor(we may want to deprecateNode.spawn_linkin favor of passing an option tospawn, for consistency withProcess). -
File.open!/2- The return value (or the anonymous function) may receive either an IO device (PID) or a file descriptor. While all functions in theFilemodule work with both, the functions in IO module may not, so may need to addFile.descriptororFile.open_descriptorfor when using the:rawoption (most cases would be fine though).
One potential benefit is that the type system itself can help with the deprecation. Many of these deprecations would have be emitted at runtime but the type system will allow us to emit them during type-checking, which will aid migration.
PS: Do not send pull request for these yet. The goal of this issue is to accumulate those entries as examples and guidance.