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

后端 未结 4 896
清歌不尽
清歌不尽 2021-01-14 12:09

In Julia, a lot of the Base and closer related functions are also written in pure Julia, and the code is easily avaible. One can skim through the repository or the local dow

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-14 12:28

    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
    

提交回复
热议问题