# Could a command like MATLAB’s \`type\` exist in Julia

**URL:** <https://discourse.julialang.org/t/could-a-command-like-matlab-s-type-exist-in-julia/75107>\
**Category:** New to Julia\
**Tags:** question, documentation, repl, matlab\
**Created:** [January 24, 2022, 7:10am UTC](https://discourse.julialang.org/t/could-a-command-like-matlab-s-type-exist-in-julia/75107 "2022-01-24T07:10:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chart/32/32049_2.png) [@chart](https://discourse.julialang.org/u/chart)\
**Post date:** [January 24, 2022, 7:10am UTC](https://discourse.julialang.org/t/could-a-command-like-matlab-s-type-exist-in-julia/75107/1 "2022-01-24T07:10:48Z")

</div>

As a new Julia user I make frequent use of REPL help prompt, and have found `@which`, `typeof()` and `fieldnames()` to be helpful in cases where docstrings don’t have much to offer. In many cases I find I still need to turn to the source to understand how I am supposed to use a method, struct or macro.

In MATLAB I could print the relevant source to the command window easily with the `type` command. Is it possible for a Julia macro to provide the functionality of MATLAB’s [`type`](https://www.mathworks.com/help/matlab/ref/type.html) command?

> `type filename` displays the contents of the specified file in the MATLAB® Command Window.

Perhaps something similar already exists to dump snippets of Julia source code to the REPL? I realize that MATLAB’s “one function per `.m` file” means that I’ve under specified what I’m asking Julia to do.

I’ve looked for other discussion on this topic but it’s difficult to form a good search query because “type” appears in so many other contexts.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [January 24, 2022, 7:19am UTC](https://discourse.julialang.org/t/could-a-command-like-matlab-s-type-exist-in-julia/75107/2 "2022-01-24T07:19:07Z")

</div>

The closest equivalent is the `@less` macro. The `@edit` macro might also be of interest.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [January 24, 2022, 7:26am UTC](https://discourse.julialang.org/t/could-a-command-like-matlab-s-type-exist-in-julia/75107/3 "2022-01-24T07:26:56Z")

</div>

> [@chart](#):
>
> `type filename` displays the contents of the specified file

that’s the entire file right? which is trivial to do but kinda useless in Julia. The only reason this function is not useless in MATLAB is that you have one function per file which is, to be honest, crazy. (and that MATLAB doesn’t have multi-dispatch)

* * *

You can easily print source code of a function (method) in Julia, [GitHub - timholy/CodeTracking.jl: It's editing-time, do you know where your methods are?](https://github.com/timholy/CodeTracking.jl) provides

```julia
@code_string

```

macro. I have this [add @code\_src by Moelf · Pull Request #253 · KristofferC/OhMyREPL.jl · GitHub](https://github.com/KristofferC/OhMyREPL.jl/pull/253) PR, which makes the result printed with syntax highlighting, if you’re into that sort of thing or is already using OhMyREPL.jl
