Skip to content

Commit f4e6ae3

Browse files
authored
Add a docstring for allowscalar(false) (#440)
1 parent 5789611 commit f4e6ae3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/GPUArraysCore/src/GPUArraysCore.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ function allowscalar(f::Base.Callable)
5858
task_local_storage(f, :ScalarIndexing, ScalarAllowed)
5959
end
6060

61+
"""
62+
allowscalar(::Bool)
63+
64+
Calling this with `false` replaces the default warning about scalar indexing
65+
(show once per session) with an error.
66+
67+
Instead of calling this with `true`, the preferred style is to allow this locally.
68+
This can be done with the `allowscalar(::Function)` method (with a `do` block)
69+
or with the [`@allowscalar`](@ref) macro.
70+
71+
Writes to `task_local_storage` for `:ScalarIndexing`. The default is `:ScalarWarn`,
72+
and this function sets `:ScalarAllowed` or `:ScalarDisallowed`.
73+
"""
6174
function allowscalar(allow::Bool=true)
6275
if allow
6376
Base.depwarn("allowscalar([true]) is deprecated, use `allowscalar() do end` or `@allowscalar` to denote exactly which operations can use scalar operations.", :allowscalar)

0 commit comments

Comments
 (0)