Skip to content

Commit

Permalink
Move atsign-method_exists docs into reflection.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Jun 1, 2016
1 parent 0edf6c1 commit 29c2866
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
17 changes: 0 additions & 17 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6917,23 +6917,6 @@ true
"""
method_exists

"""
@method_exists(f, tt)
Determine whether the given generic function `f` has a method matching
the given tuple `tt` of argument types. When used in a function, if
the method exists at the time the function is compiled, this statement
simple gets replaced by `true` (and hence has no runtime overhead). If
the function does not exist, then it is equivalent to the function
form, `method_exists`.
```jldoctest
julia> @method_exists(length, Tuple{Array})
true
```
"""
:@method_exists

"""
nextpow(a, x)
Expand Down
17 changes: 17 additions & 0 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,23 @@ end
# For static evaluation of method_exists, when it evaluates to true.
# We don't evaluate it at compile-time when false, because someone
# might define the missing method later.
"""
@method_exists(f, tt)
Determine whether the given generic function `f` has a method matching
the given tuple `tt` of argument types. When used in a function, if
the method exists at the time the function is compiled, this statement
simply gets replaced by `true` (and hence has no runtime overhead). If
the function does not exist, then it is equivalent to the function
form, `method_exists`.
```jldoctest
julia> @method_exists(length, Tuple{Array})
true
```
"""
:@method_exists

macro method_exists(f, tt)
exmt = :(typeof($f).name.mt) # get the method table for f
# Form the tuple-type of the function + argument types
Expand Down

0 comments on commit 29c2866

Please sign in to comment.