summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEksperimental <eksperimental@users.noreply.github.com>2018-07-11 14:51:25 +0700
committerJosé Valim <jose.valim@gmail.com>2018-07-11 09:51:25 +0200
commit88ef0053d9aece5b43aebf9a0a3646dec5582bcb (patch)
tree58eec90133fbd301a0bec4fa11a88483a0a7a1c6
parent2583b1da17c9bbf6753c9fdcb340d96a661d4324 (diff)
downloadelixir-88ef0053d9aece5b43aebf9a0a3646dec5582bcb.tar.gz
Improve docs and type for Kernel.send/2 & Process.send/3 (#7862)
Kernel.send/2: - Simplify/Improve description of `dest` Process.send/3: - Refer to `dest` and not just "process" - Duplicate definition of `dest` in Process.send/3
-rw-r--r--lib/elixir/lib/kernel.ex8
-rw-r--r--lib/elixir/lib/process.ex19
2 files changed, 20 insertions, 7 deletions
diff --git a/lib/elixir/lib/kernel.ex b/lib/elixir/lib/kernel.ex
index 25b2cc571..657f8e24c 100644
--- a/lib/elixir/lib/kernel.ex
+++ b/lib/elixir/lib/kernel.ex
@@ -797,9 +797,9 @@ defmodule Kernel do
@doc """
Sends a message to the given `dest` and returns the message.
- `dest` may be a remote or local PID, a (local) port, a locally
- registered name, or a tuple `{registered_name, node}` for a registered
- name at another node.
+ `dest` may be a remote or local PID, a local port, a locally
+ registered name, or a tuple in the form of `{registered_name, node}` for a
+ registered name at another node.
Inlined by the compiler.
@@ -809,7 +809,7 @@ defmodule Kernel do
:hello
"""
- @spec send(dest :: pid | port | atom | {atom, node}, message) :: message when message: any
+ @spec send(dest :: Process.dest(), message) :: message when message: any
def send(dest, message) do
:erlang.send(dest, message)
end
diff --git a/lib/elixir/lib/process.ex b/lib/elixir/lib/process.ex
index c23713d42..2db5ae0c8 100644
--- a/lib/elixir/lib/process.ex
+++ b/lib/elixir/lib/process.ex
@@ -30,6 +30,15 @@ defmodule Process do
Inlined by the compiler.
"""
+
+ @typedoc """
+ A process destination.
+
+ A remote or local PID, a local port, a locally registered name, or a tuple in
+ the form of `{registered_name, node}` for a registered name at another node.
+ """
+ @type dest :: pid | port | registered_name :: atom | {registered_name :: atom, node}
+
@spec alive?(pid) :: boolean
defdelegate alive?(pid), to: :erlang, as: :is_process_alive
@@ -220,7 +229,11 @@ defmodule Process do
end
@doc """
- Sends a message to the given process.
+ Sends a message to the given `dest`.
+
+ `dest` may be a remote or local PID, a local port, a locally
+ registered name, or a tuple in the form of `{registered_name, node}` for a
+ registered name at another node.
Inlined by the compiler.
@@ -242,7 +255,7 @@ defmodule Process do
"""
@spec send(dest, msg, [option]) :: :ok | :noconnect | :nosuspend
- when dest: pid | port | atom | {atom, node},
+ when dest: dest(),
msg: any,
option: :noconnect | :nosuspend
defdelegate send(dest, msg, options), to: :erlang
@@ -395,7 +408,7 @@ defmodule Process do
* `object` is either a `pid` of the monitored process (if monitoring
a PID) or `{name, node}` (if monitoring a remote or local name);
* `reason` is the exit reason.
-
+
If the process is already dead when calling `Process.monitor/1`, a
`:DOWN` message is delivered immediately.