Skip to content

Commit

Permalink
Update repr docstring to hint what it stands for. (#56761)
Browse files Browse the repository at this point in the history
- Change `repr` docstring from "Create a string from any
value ..." to "Create a string representation of any value ...".
- Document that it typically emits parseable Julia code

---------

Co-authored-by: Ian Butterworth <[email protected]>
  • Loading branch information
nathanrboyer and IanButterworth authored Dec 11, 2024
1 parent d269d7d commit 92d3702
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/strings/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ print(io::IO, s::Union{String,SubString{String}}) = (write(io, s); nothing)
"""
repr(x; context=nothing)
Create a string from any value using the 2-argument `show(io, x)` function.
Create a string representation of any value using the 2-argument `show(io, x)` function,
which aims to produce a string that is parseable Julia code, where possible.
i.e. `eval(Meta.parse(repr(x))) == x` should hold true.
You should not add methods to `repr`; define a [`show`](@ref) method instead.
The optional keyword argument `context` can be set to a `:key=>value` pair, a
Expand Down

0 comments on commit 92d3702

Please sign in to comment.