Skip to content

Commit

Permalink
some improvements to dump()
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 29, 2011
1 parent bf82535 commit f4f9cfa
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions j/show.j
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,21 @@ function show(e::UnionTooComplexError)
show(e.types)
end
dump(t::Type) = print(t)
dump(t::Tuple) = print(t)
function dump{T}(x::T)
print(T,'(')
for field = T.names
print(field, '=')
show(getfield(x, field))
print(',')
function dump(x)
T = typeof(x)
if isa(x,Array)
showempty(x)
elseif isa(T,StructKind)
print(T,'(')
for field = T.names
print(field, '=')
dump(getfield(x, field))
print(',')
end
println(')')
else
show(x)
end
println(')')
end
showempty{T}(a::Array{T}) = print("Array($T,$(size(a)))")
Expand Down

0 comments on commit f4f9cfa

Please sign in to comment.