JuliaLang/julia — pull request #1592 by toivoh (2012-11-22 09:41:03+00:00)
Title: RFC: Make print show ASTs unquoted

This patch makes `print` show ASTs unquoted, while `show` still shows the quoted version, e.g.

julia> show(:(f(x,y)=x*y))
:( f(x, y) = *(x, y) )
julia> print(:(f(x,y)=x*y))
f(x, y) = *(x, y)

This would be consistent with the current treatment of symbols:

julia> show(:x)
:x
julia> print(:x)
x

I think the policy for type-specific `print` methods is to provide them for types that have an intrinsic string representation. I think one could argue that the intrinsic string representation of an AST is the source code that it represents, which would also motivate the current practice of letting `print` print symbols unquoted.

As an aside, this change would make the output of the `@show` macro in #1591 more consistent,
i.e. making `@show 2^2` print `^(2,2) = 4` instead of `^:( (2,2) :) = 4`.
More generally, it is sometimes useful to print an AST unquoted. Though `Base.show_unquoted` works, `print` is more terse and works also through e.g. `string(ex)`.

Does this seem like a reasonable policy? Thoughts?