You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/elixir/pages/references/typespecs.md
+7-4Lines changed: 7 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -62,9 +62,13 @@ The notation to represent the union of types is the pipe `|`. For example, the t
62
62
> #### Differences with set-theoretic types {: .warning}
63
63
>
64
64
> While they do share some similarities, the types below do not map one-to-one
65
-
> to the new types from the set theoretic type system.
65
+
> to the new types from the set-theoretic type system.
66
+
>
66
67
> For example, there is no plan to support subsets of the `integer()` type such
67
68
> as positive, ranges or literals.
69
+
>
70
+
> Furthermore, set-theoretic types support the full range of set operations,
71
+
> including intersections and negations.
68
72
69
73
### Basic types
70
74
@@ -388,10 +392,9 @@ Note you don't need to define a behaviour in order to dynamically dispatch on a
388
392
389
393
Optional callbacks are callbacks that callback modules may implement if they want to, but are not required to. Usually, behaviour modules know if they should call those callbacks based on configuration, or they check if the callbacks are defined with `function_exported?/3` or `macro_exported?/3`.
390
394
391
-
> Testing Optional Callbacks {: .warning}
395
+
> ### Unloaded modules {: .warning}
392
396
>
393
-
> `mix test` may exhibit unexpected behaviour when testing a conditional call to an optional callback gated
394
-
> on `function_exported?/3`, see the documentation on this function for details.
397
+
> `function_exported?/3` (and `macro_exported?/3`) do *not* load the module in case it is not loaded and Elixir lazily loads modules by default (except on releases). So in practice you will want to invoke `Code.ensure_loaded?/1` before checking if the function/macro is exported. See the documentation for `function_exported?/3` for examples.
395
398
396
399
Optional callbacks can be defined through the `@optional_callbacks` module attribute, which has to be a keyword list with function or macro name as key and arity as value. For example:
0 commit comments