Skip to content

Commit

Permalink
better printing of builtins, and disallow adding methods to them
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jan 26, 2016
1 parent a17deee commit 12e30da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions base/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function writemime(io::IO, ::MIME"text/plain", f::Function)
print(io, ns, " (", what, " with $n $m)")
end

function writemime(io::IO, ::MIME"text/plain", f::Builtin)
print(io, typeof(f).name.mt.name, " (built-in function)")
end

# writemime for ranges, e.g.
# 3-element UnitRange{Int64,Int}
# 1,2,3
Expand Down
3 changes: 3 additions & 0 deletions src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,9 @@ JL_DLLEXPORT void jl_method_def(jl_svec_t *argdata, jl_lambda_info_t *f, jl_valu
mt = ((jl_datatype_t*)ftype)->name->mt;
name = mt->name;

if (jl_subtype(ftype, jl_builtin_type, 0))
jl_error("cannot add methods to a builtin function");

jl_check_static_parameter_conflicts(f, tvars, name);

// TODO
Expand Down

0 comments on commit 12e30da

Please sign in to comment.