diff --git a/base/essentials.jl b/base/essentials.jl index 42ecf5ae40bbc..04d49dcef2e15 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -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 diff --git a/doc/src/stdlib/base.md b/doc/src/stdlib/base.md index 15587998cb32d..a6afa955fe6ea 100644 --- a/doc/src/stdlib/base.md +++ b/doc/src/stdlib/base.md @@ -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)