Skip to content

Commit

Permalink
behaviour -> behavior when not about OTP behaviours (elixir-lang#13240)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabiwara authored Jan 9, 2024
1 parent b1a3e26 commit 8cde231
Show file tree
Hide file tree
Showing 38 changed files with 91 additions and 91 deletions.
16 changes: 8 additions & 8 deletions lib/elixir/lib/code.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ defmodule Code do
Utilities for managing code compilation, code evaluation, and code loading.
This module complements Erlang's [`:code` module](`:code`)
to add behaviour which is specific to Elixir. For functions to
to add behavior which is specific to Elixir. For functions to
manipulate Elixir's AST (rather than evaluating it), see the
`Macro` module.
## Working with files
This module contains three functions for compiling and evaluating files.
Here is a summary of them and their behaviour:
Here is a summary of them and their behavior:
* `require_file/2` - compiles a file and tracks its name. It does not
compile the file again if it has been previously required.
Expand Down Expand Up @@ -710,8 +710,8 @@ defmodule Code do
specially because a function is named `defmodule`, `def`, or the like. This
principle mirrors Elixir's goal of being an extensible language where
developers can extend the language with new constructs as if they were
part of the language. When it is absolutely necessary to change behaviour
based on the name, this behaviour should be configurable, such as the
part of the language. When it is absolutely necessary to change behavior
based on the name, this behavior should be configurable, such as the
`:locals_without_parens` option.
## Running the formatter
Expand Down Expand Up @@ -855,7 +855,7 @@ defmodule Code do
* Newlines before certain operators (such as the pipeline operators)
and before other operators (such as comparison operators)
The behaviours above are not guaranteed. We may remove or add new
The behaviors above are not guaranteed. We may remove or add new
rules in the future. The goal of documenting them is to provide better
understanding on what to expect from the formatter.
Expand Down Expand Up @@ -1145,7 +1145,7 @@ defmodule Code do
* `:static_atoms_encoder` - the static atom encoder function, see
"The `:static_atoms_encoder` function" section below. Note this
option overrides the `:existing_atoms_only` behaviour for static
option overrides the `:existing_atoms_only` behavior for static
atoms but `:existing_atoms_only` is still used for dynamic atoms,
such as atoms with interpolations.
Expand Down Expand Up @@ -1627,7 +1627,7 @@ defmodule Code do
error. You may be set it to `:warn` if you want undefined variables to
emit a warning and expand as to a local call to the zero-arity function
of the same name (for example, `node` would be expanded as `node()`).
This `:warn` behaviour only exists for compatibility reasons when working
This `:warn` behavior only exists for compatibility reasons when working
with old dependencies.
It always returns `:ok`. Raises an error for invalid options.
Expand Down Expand Up @@ -1961,7 +1961,7 @@ defmodule Code do
@doc """
Returns `true` if the module is loaded.
This function doesn't attempt to load the module. For such behaviour,
This function doesn't attempt to load the module. For such behavior,
`ensure_loaded?/1` can be used.
## Examples
Expand Down
4 changes: 2 additions & 2 deletions lib/elixir/lib/collectable.ex
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ end

defimpl Collectable, for: List do
def into(list) do
# TODO: Change the behaviour so the into always comes last on Elixir v2.0
# TODO: Change the behavior so the into always comes last on Elixir v2.0
if list != [] do
IO.warn(
"the Collectable protocol is deprecated for non-empty lists. The behaviour of " <>
"the Collectable protocol is deprecated for non-empty lists. The behavior of " <>
"Enum.into/2 and \"for\" comprehensions with an :into option is incorrect " <>
"when collecting into non-empty lists. If you're collecting into a non-empty keyword " <>
"list, consider using Keyword.merge/2 instead. If you're collecting into a non-empty " <>
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/config/provider.ex
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ defmodule Config.Provider do
"""
the application #{inspect(app)} has a different value set #{path(key, path)} \
during runtime compared to compile time. Since this application environment entry was \
marked as compile time, this difference can lead to different behaviour than expected:
marked as compile time, this difference can lead to different behavior than expected:
* Compile time value #{return_to_text(compile_return)}
* Runtime value #{return_to_text(runtime_return)}
Expand Down
8 changes: 4 additions & 4 deletions lib/elixir/lib/enum.ex
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ defmodule Enum do
After all, if we want to traverse every element on a list, the longer the
list, the more elements we need to traverse, and the longer it will take.
This linear behaviour should also be expected on operations like `count/1`,
This linear behavior should also be expected on operations like `count/1`,
`member?/2`, `at/2` and similar. While Elixir does allow data types to
provide performant variants for such operations, you should not expect it
to always be available, since the `Enum` module is meant to work with a
large variety of data types and not all data types can provide optimized
behaviour.
behavior.
Finally, note the functions in the `Enum` module are eager: they will
traverse the enumerable as soon as they are invoked. This is particularly
Expand Down Expand Up @@ -4020,7 +4020,7 @@ defmodule Enum do
@doc """
Reduces over two enumerables halting as soon as either enumerable is empty.
In practice, the behaviour provided by this function can be achieved with:
In practice, the behavior provided by this function can be achieved with:
Enum.reduce(Stream.zip(left, right), acc, reducer)
Expand Down Expand Up @@ -4054,7 +4054,7 @@ defmodule Enum do
The reducer will receive 2 args: a list of elements (one from each enum) and the
accumulator.
In practice, the behaviour provided by this function can be achieved with:
In practice, the behavior provided by this function can be achieved with:
Enum.reduce(Stream.zip(enums), acc, reducer)
Expand Down
8 changes: 4 additions & 4 deletions lib/elixir/lib/file.ex
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ defmodule File do
Note: The command `mv` in Unix-like systems behaves differently depending on
whether `source` is a file and the `destination` is an existing directory.
We have chosen to explicitly disallow this behaviour.
We have chosen to explicitly disallow this behavior.
## Examples
Expand Down Expand Up @@ -822,7 +822,7 @@ defmodule File do
The function receives arguments for `source_file` and `destination_file`. It should
return `true` if the existing file should be overwritten, `false` if otherwise.
The default callback returns `true`. On earlier versions, this callback could be
given as third argument, but such behaviour is now deprecated.
given as third argument, but such behavior is now deprecated.
"""
@spec cp(Path.t(), Path.t(), on_conflict: on_conflict_callback) :: :ok | {:error, posix}
Expand Down Expand Up @@ -895,7 +895,7 @@ defmodule File do
Note: The command `cp` in Unix-like systems behaves differently depending on
whether `destination` is an existing directory or not. We have chosen to
explicitly disallow this behaviour. If `source` is a `file` and `destination`
explicitly disallow this behavior. If `source` is a `file` and `destination`
is a directory, `{:error, :eisdir}` will be returned.
## Options
Expand All @@ -904,7 +904,7 @@ defmodule File do
The function receives arguments for `source` and `destination`. It should return
`true` if the existing file should be overwritten, `false` if otherwise. The default
callback returns `true`. On earlier versions, this callback could be given as third
argument, but such behaviour is now deprecated.
argument, but such behavior is now deprecated.
* `:dereference_symlinks` - (since v1.14.0) By default, this function will copy symlinks
by creating symlinks that point to the same location. This option forces symlinks to be
Expand Down
14 changes: 7 additions & 7 deletions lib/elixir/lib/float.ex
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ defmodule Float do
## Known issues
The behaviour of `floor/2` for floats can be surprising. For example:
The behavior of `floor/2` for floats can be surprising. For example:
iex> Float.floor(12.52, 2)
12.51
One may have expected it to floor to 12.52. This is not a bug.
Most decimal fractions cannot be represented as a binary floating point
and therefore the number above is internally represented as 12.51999999,
which explains the behaviour above.
which explains the behavior above.
## Examples
Expand Down Expand Up @@ -254,15 +254,15 @@ defmodule Float do
The operation is performed on the binary floating point, without a
conversion to decimal.
The behaviour of `ceil/2` for floats can be surprising. For example:
The behavior of `ceil/2` for floats can be surprising. For example:
iex> Float.ceil(-12.52, 2)
-12.51
One may have expected it to ceil to -12.52. This is not a bug.
Most decimal fractions cannot be represented as a binary floating point
and therefore the number above is internally represented as -12.51999999,
which explains the behaviour above.
which explains the behavior above.
This function always returns floats. `Kernel.trunc/1` may be used instead to
truncate the result to an integer afterwards.
Expand Down Expand Up @@ -305,16 +305,16 @@ defmodule Float do
## Known issues
The behaviour of `round/2` for floats can be surprising. For example:
The behavior of `round/2` for floats can be surprising. For example:
iex> Float.round(5.5675, 3)
5.567
One may have expected it to round to the half up 5.568. This is not a bug.
Most decimal fractions cannot be represented as a binary floating point
and therefore the number above is internally represented as 5.567499999,
which explains the behaviour above. If you want exact rounding for decimals,
you must use a decimal library. The behaviour above is also in accordance
which explains the behavior above. If you want exact rounding for decimals,
you must use a decimal library. The behavior above is also in accordance
to reference implementations, such as "Correctly Rounded Binary-Decimal and
Decimal-Binary Conversions" by David M. Gay.
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/io/ansi.ex
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ defmodule IO.ANSI do
The named sequences are represented by atoms.
It will also append an `IO.ANSI.reset/0` to the chardata when a conversion is
performed. If you don't want this behaviour, use `format_fragment/2`.
performed. If you don't want this behavior, use `format_fragment/2`.
An optional boolean parameter can be passed to enable or disable
emitting actual ANSI codes. When `false`, no ANSI codes will be emitted.
Expand Down
14 changes: 7 additions & 7 deletions lib/elixir/lib/kernel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ defmodule Kernel do
### Supporting documents
Under the "Pages" section in sidebar you will find tutorials, guides,
and reference documents that outline Elixir semantics and behaviours
and reference documents that outline Elixir semantics and behaviors
in more detail. Those are:
* [Compatibility and deprecations](compatibility-and-deprecations.md) - lists
Expand Down Expand Up @@ -548,10 +548,10 @@ defmodule Kernel do
* `exit({:shutdown, term})`
Exiting with any other reason is considered abnormal and treated
as a crash. This means the default supervisor behaviour kicks in,
as a crash. This means the default supervisor behavior kicks in,
error reports are emitted, and so forth.
This behaviour is relied on in many different places. For example,
This behavior is relied on in many different places. For example,
`ExUnit` uses `exit(:shutdown)` when exiting the test process to
signal linked processes, supervision trees and so on to politely
shut down too.
Expand Down Expand Up @@ -2362,7 +2362,7 @@ defmodule Kernel do
Keys in the `Enumerable` that don't exist in the struct are automatically
discarded. Note that keys must be atoms, as only atoms are allowed when
defining a struct. If there are duplicate keys in the `Enumerable`, the last
entry will be taken (same behaviour as `Map.new/1`).
entry will be taken (same behavior as `Map.new/1`).
This function is useful for dynamically creating and updating structs, as
well as for converting maps to structs; in the latter case, just inserting
Expand Down Expand Up @@ -2410,7 +2410,7 @@ defmodule Kernel do
@doc """
Similar to `struct/2` but checks for key validity.
The function `struct!/2` emulates the compile time behaviour
The function `struct!/2` emulates the compile time behavior
of structs. This means that:
* when building a struct, as in `struct!(SomeStruct, key: :value)`,
Expand Down Expand Up @@ -3389,7 +3389,7 @@ defmodule Kernel do
The pin operator will check if the values are equal, using `===/2`, while
patterns have their own rules when matching maps, lists, and so forth.
Such behaviour is not specific to `match?/2`. The following code also
Such behavior is not specific to `match?/2`. The following code also
throws an exception:
attrs = %{x: 1}
Expand Down Expand Up @@ -3928,7 +3928,7 @@ defmodule Kernel do
one element, which is the number itself.
If first is more than last, the range will be decreasing from first
to last, albeit this behaviour is deprecated. Instead prefer to
to last, albeit this behavior is deprecated. Instead prefer to
explicitly list the step with `first..last//-1`.
See the `Range` module for more information.
Expand Down
14 changes: 7 additions & 7 deletions lib/elixir/lib/kernel/special_forms.ex
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ defmodule Kernel.SpecialForms do
Elixir won't emit any warnings though, since the alias
was not explicitly defined.
Both warning behaviours could be changed by explicitly
Both warning behaviors could be changed by explicitly
setting the `:warn` option to `true` or `false`.
"""
Expand Down Expand Up @@ -674,7 +674,7 @@ defmodule Kernel.SpecialForms do
Elixir won't emit any warnings though, since the import
was not explicitly defined.
Both warning behaviours could be changed by explicitly
Both warning behaviors could be changed by explicitly
setting the `:warn` option to `true` or `false`.
## Ambiguous function/macro names
Expand Down Expand Up @@ -888,7 +888,7 @@ defmodule Kernel.SpecialForms do
At first, there is nothing in this example that actually reveals it is a
macro. But what is happening is that, at compilation time, `squared(5)`
becomes `5 * 5`. The argument `5` is duplicated in the produced code, we
can see this behaviour in practice though because our macro actually has
can see this behavior in practice though because our macro actually has
a bug:
import Math
Expand All @@ -915,7 +915,7 @@ defmodule Kernel.SpecialForms do
my_number.() * my_number.()
Which invokes the function twice, explaining why we get the printed value
twice! In the majority of the cases, this is actually unexpected behaviour,
twice! In the majority of the cases, this is actually unexpected behavior,
and that's why one of the first things you need to keep in mind when it
comes to macros is to **not unquote the same value more than once**.
Expand Down Expand Up @@ -1444,7 +1444,7 @@ defmodule Kernel.SpecialForms do
[elixir: :prolog]
Given the grandparents of Erlang and Prolog were nil, those values were
filtered out. If you don't want this behaviour, a simple option is to
filtered out. If you don't want this behavior, a simple option is to
move the filter inside the do-block:
iex> languages = [elixir: :erlang, erlang: :prolog, prolog: nil]
Expand Down Expand Up @@ -1496,7 +1496,7 @@ defmodule Kernel.SpecialForms do
*Available since Elixir v1.8*.
While the `:into` option allows us to customize the comprehension behaviour
While the `:into` option allows us to customize the comprehension behavior
to a given data type, such as putting all of the values inside a map or inside
a binary, it is not always enough.
Expand Down Expand Up @@ -1624,7 +1624,7 @@ defmodule Kernel.SpecialForms do
iex> width
nil
The behaviour of any expression in a clause is the same as if it was
The behavior of any expression in a clause is the same as if it was
written outside of `with`. For example, `=` will raise a `MatchError`
instead of returning the non-matched value:
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/list.ex
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ defmodule List do
charlists in IEx when you encounter them, which shows you the type, description
and also the raw representation in one single summary.
The rationale behind this behaviour is to better support
The rationale behind this behavior is to better support
Erlang libraries which may return text as charlists
instead of Elixir strings. In Erlang, charlists are the default
way of handling strings, while in Elixir it's binaries. One
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/module/types/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Module.Types.Helpers do
#{hint()} all expressions given to binaries are assumed to be of type \
integer() unless said otherwise. For example, <<expr>> assumes "expr" \
is an integer. Pass a modifier, such as <<expr::float>> or <<expr::binary>>, \
to change the default behaviour.
to change the default behavior.
"""
end)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/path.ex
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ defmodule Path do
Path.relative("/bar/foo.ex") #=> "bar/foo.ex"
"""
# Note this function does not expand paths because the behaviour
# Note this function does not expand paths because the behavior
# is ambiguous. If we expand it before converting to relative, then
# "/usr/../../foo" means "/foo". If we expand it after, it means "../foo".
# We could expand only relative paths but it is best to say it never
Expand Down
4 changes: 2 additions & 2 deletions lib/elixir/lib/process.ex
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ defmodule Process do
@doc """
Sends an exit signal with the given `reason` to `pid`.
The following behaviour applies if `reason` is any term except `:normal`
The following behavior applies if `reason` is any term except `:normal`
or `:kill`:
1. If `pid` is not trapping exits, `pid` will exit with the given
Expand Down Expand Up @@ -624,7 +624,7 @@ defmodule Process do
exits with a reason other than `:normal` (which is also the exit reason used
when a process finishes its job) and `pid1` is not trapping exits (see
`flag/2`), then `pid1` will exit with the same reason as `pid2` and in turn
emit an exit signal to all its other linked processes. The behaviour when
emit an exit signal to all its other linked processes. The behavior when
`pid1` is trapping exits is described in `exit/2`.
See `:erlang.link/1` for more information.
Expand Down
4 changes: 2 additions & 2 deletions lib/elixir/lib/protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ defmodule Protocol do
Although the implementation above is arguably not a reasonable
one. For example, it makes no sense to say a PID or an integer
have a size of `0`. That's one of the reasons why `@fallback_to_any`
is an opt-in behaviour. For the majority of protocols, raising
an error when a protocol is not implemented is the proper behaviour.
is an opt-in behavior. For the majority of protocols, raising
an error when a protocol is not implemented is the proper behavior.
## Multiple implementations
Expand Down
Loading

0 comments on commit 8cde231

Please sign in to comment.