Skip to content

Commit

Permalink
Document macros goto and label (#23656)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschauer authored and JeffBezanson committed Sep 12, 2017
1 parent a5e9844 commit 8480c06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,24 @@ macro inbounds(blk)
Expr(:inbounds, :pop))
end

"""
@label name
Labels a statement with the symbolic label `name`. The label marks the end-point
of an unconditional jump with [`@goto name`](@ref).
"""
macro label(name::Symbol)
return esc(Expr(:symboliclabel, name))
end

"""
@goto name
`@goto name` unconditionally jumps to the statement at the location [`@label name`](@ref).
`@label` and `@goto` cannot create jumps to different top-level statements. Attempts cause an
error. To still use `@goto`, enclose the `@label` and `@goto` in a block.
"""
macro goto(name::Symbol)
return esc(Expr(:symbolicgoto, name))
end
Expand Down
2 changes: 2 additions & 0 deletions doc/src/stdlib/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ Base.@noinline
Base.@nospecialize
Base.gensym
Base.@gensym
Base.@goto
Base.@label
Base.@polly
Base.parse(::AbstractString, ::Int)
Base.parse(::AbstractString)
Expand Down

0 comments on commit 8480c06

Please sign in to comment.