This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro expect(pred) | |
:( ($esc(pred)) ? nothing : error($"error: expected $pred == true") ) | |
end | |
is_expr(ex, head::Symbol) = (isa(ex, Expr) && (ex.head == head)) | |
function split_fdef(fdef::Expr) | |
@expect (fdef.head == :function) || (fdef.head == :(=)) | |
@expect length(fdef.args) == 2 | |
signature, body = tuple(fdef.args...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code = quote | |
function show_body_lines(io::IO, ex) | |
args = is_expr(ex, :block) ? ex.args : {ex} | |
for arg in args | |
if !is_linenumber(arg); print(io, '\n'); end | |
show(io, arg) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("recshow.jl") | |
type T | |
x | |
y | |
end | |
type Unshowable; end | |
show(io::IO, x::Unshowable) = error("Tried to show Unshowable()") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---- ObjNode: capture of an object's output to show() ----------------------- | |
type ObjNode | |
# actual capture | |
obj | |
reused::Bool | |
items::Vector # ObjNode:s and strings/chars | |
# scratch space for recshow etc | |
strlen::Integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# union of immutable types not to freeze/unfreeze | |
typealias NoFreeze Union(Number, String) | |
type Frozen{T,COUNT} | |
item::T | |
watchers::Set{WeakRef} | |
end | |
typealias FrozenArray{T,N,COUNT} Frozen{Array{T,N},COUNT} |
NewerOlder