Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions base/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const is_expr = isexpr
"""
gensym([tag])

Generates a symbol which will not conflict with other variable names (in the same module).
Generate a symbol unique among all calls to this function within the same process.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that it is definitely not unique among names in the process (as the failed tests show), but only from context of defining one module

If a string or symbol tag argument is specified, it is included in the generated name.
"""
gensym() = ccall(:jl_gensym, Ref{Symbol}, ())

Expand All @@ -19,10 +20,10 @@ gensym(ss::String...) = map(gensym, ss)
gensym(s::Symbol) = ccall(:jl_tagged_gensym, Ref{Symbol}, (Ptr{UInt8}, Csize_t), s, -1 % Csize_t)

"""
@gensym
@gensym var1 var2 ...

Generates a gensym symbol for a variable. For example, `@gensym x y` is transformed into
`x = gensym("x"); y = gensym("y")`.
Generate symbols with [`gensym`](@ref) and assign them to the given variables.
For example, `@gensym x y` is transformed into `x = gensym("x"); y = gensym("y")`.
"""
macro gensym(names...)
blk = Expr(:block)
Expand Down