Skip to content

Commit de06764

Browse files
author
José Valim
committed
apply is a macro
1 parent 4d0d7e8 commit de06764

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -291,23 +291,6 @@ defmodule Kernel do
291291
"""
292292
defmacro left !== right
293293

294-
@doc """
295-
Returns an integer or float which is the arithmetical absolute value of `number`.
296-
297-
Allowed in guard tests.
298-
299-
## Examples
300-
301-
iex> abs(-3.33)
302-
3.33
303-
iex> abs(-3)
304-
3
305-
"""
306-
@spec abs(number) :: number
307-
def abs(number) do
308-
:erlang.abs(number)
309-
end
310-
311294
@doc """
312295
Invokes the given `fun` with the array of arguments `args`.
313296
@@ -317,10 +300,7 @@ defmodule Kernel do
317300
4
318301
319302
"""
320-
@spec apply((... -> any), list) :: term
321-
def apply(fun, args) do
322-
:erlang.apply(fun, args)
323-
end
303+
defmacro apply(fun, args)
324304

325305
@doc """
326306
Invokes the given `fun` from `module` with the array of arguments `args`.
@@ -331,9 +311,23 @@ defmodule Kernel do
331311
[3,2,1]
332312
333313
"""
334-
@spec apply(atom, atom, list) :: term
335-
def apply(module, fun, args) do
336-
:erlang.apply(module, fun, args)
314+
defmacro apply(module, fun, args)
315+
316+
@doc """
317+
Returns an integer or float which is the arithmetical absolute value of `number`.
318+
319+
Allowed in guard tests.
320+
321+
## Examples
322+
323+
iex> abs(-3.33)
324+
3.33
325+
iex> abs(-3)
326+
3
327+
"""
328+
@spec abs(number) :: number
329+
def abs(number) do
330+
:erlang.abs(number)
337331
end
338332

339333
@doc """
@@ -1018,7 +1012,7 @@ defmodule Kernel do
10181012
10191013
## Examples
10201014
1021-
iex> round(5.5)
1015+
iex> round(5.5)
10221016
6
10231017
10241018
"""
@@ -1458,7 +1452,7 @@ defmodule Kernel do
14581452
where the last line is a quoted representation of
14591453
14601454
[bar: nil | integer]
1461-
1455+
14621456
## Documentation
14631457
14641458
By default records are not documented and have `@moduledoc` set to false.

0 commit comments

Comments
 (0)