Skip to content

Clarify that repr should make julia code #30757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
14 changes: 8 additions & 6 deletions base/strings/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,18 @@ end
"""
repr(x; context=nothing)

Create a string from any value using the [`show`](@ref) function.
Create a representation of `x` similar to how `x` would be defined in Julia code.
In general `eval(Meta.parse(repr(x)))` should be equal to `x`,
where this is not possible `repr(x)` should not `parse`.

The optional keyword argument `context` can be set to an `IO` or [`IOContext`](@ref)
object whose attributes are used for the I/O stream passed to `show`.

Note that `repr(x)` is usually similar to how the value of `x` would
be entered in Julia. See also [`repr(MIME("text/plain"), x)`](@ref) to instead
See also [`repr(MIME("text/plain"), x)`](@ref) to instead
return a "pretty-printed" version of `x` designed more for human consumption,
equivalent to the REPL display of `x`.

By default `repr` falls back to the [`show`](@ref) function.
The optional keyword argument `context` can be set to an `IO` or [`IOContext`](@ref)
object whose attributes are used for the I/O stream passed to `show`.

# Examples
```jldoctest
julia> repr(1)
Expand Down