Skip to content

Commit

Permalink
Deprecated the Behaviour module and its macros (elixir-lang#5037)
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide authored Jul 20, 2016
1 parent b82d8fb commit 7f9b760
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/elixir/lib/behaviour.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ defmodule Behaviour do
@moduledoc """
This module has been deprecated.
Instead of `defcallback`, one can simply use `@callback`.
Instead of `defmacrocallback`, one can simply use `@macrocallback`.
Instead of `__behaviour__(:callbacks)`, one can simply use `behaviour_info(:callbacks)`.
"""
Instead of `defcallback/1` and `defmacrocallback/1`, the `@callback` and
`@macrocallback` module attributes can be used (respectively). See the
documentation for `Module` for more information on these attributes.
# TODO: Deprecate by 1.4
Instead of `MyModule.__behaviour__(:callbacks)`,
`MyModule.behaviour_info(:callbacks)` can be used.
"""

@doc """
Defines a function callback according to the given type specification.
Expand Down Expand Up @@ -79,6 +80,12 @@ defmodule Behaviour do
@doc false
defmacro __using__(_) do
quote do
warning =
"the Behaviour module is deprecated. Instead of using this module, " <>
"just use the @callback and @macrocallback module attributes. See the " <>
"documentation for Module for more information on these attributes."
IO.warn(warning)

@doc false
def __behaviour__(:callbacks) do
__MODULE__.behaviour_info(:callbacks)
Expand Down

0 comments on commit 7f9b760

Please sign in to comment.