How to print in REPL the code of functions in Julia?

三世轮回 提交于 2019-12-01 11:04:22

Though this may not be what the OP is looking for, @less is very convenient to read the underlying code (so I very often use it). For example,

julia> @less 1 + 2

gives

+(x::Int, y::Int) = box(Int,add_int(unbox(Int,x),unbox(Int,y)))

which corresponds to the line given by

julia> @which 1 + 2
+(x::Int64, y::Int64) at int.jl:8

This is not currently supported but probably will be in the future.

@edit functioninquestion() will open up your editor to the location of the method given. It probably wouldn't be to hard to take the same information used by @edit and use it to open the file and skip to the method definition, and then display it directly in the REPL (or Jupyter). EDIT: While I was answering, somebody else mentioned @less, which seems to do exactly what you want already.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!