# How to check that a Symbol represents a function

**URL:** <https://discourse.julialang.org/t/how-to-check-that-a-symbol-represents-a-function/55124>\
**Category:** General Usage\
**Created:** [February 12, 2021, 8:32am UTC](https://discourse.julialang.org/t/how-to-check-that-a-symbol-represents-a-function/55124 "2021-02-12T08:32:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maajdl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maajdl/32/22838_2.png) [@maajdl](https://discourse.julialang.org/u/maajdl)\
**Post date:** [February 12, 2021, 8:32am UTC](https://discourse.julialang.org/t/how-to-check-that-a-symbol-represents-a-function/55124/1 "2021-02-12T08:32:52Z")

</div>

Hello

I want to go through all the names in a module and find out those that represent a function.  
I tried something like:

```julia
typeof(eval(:foo))

```

and in case `:foo` is a function, it returns:

```julia
typeof(foo)

```

From this I can see (with my eyes) that it is a function, but I can’t figure out how to see it in Julia.  
Could you tell me how to see if a Symbol represents a function?

Thanks,

Michel

---

<div class="post-metadata">

**Author:** ![mike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike/32/39_2.png) [@mike](https://discourse.julialang.org/u/mike)\
**Post date:** [February 12, 2021, 8:38am UTC](https://discourse.julialang.org/t/how-to-check-that-a-symbol-represents-a-function/55124/2 "2021-02-12T08:38:25Z")

</div>

`getfield` is what you’re wanting:

```julia
julia> foo(x) = x
foo (generic function with 1 method)

julia> isa(getfield(Main, :foo), Function)
true

```

`isdefined(Main, :foo)` can be helpful too to make sure the binding actually exists before using `getfield`.

---

<div class="post-metadata">

**Author:** ![maajdl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maajdl/32/22838_2.png) [@maajdl](https://discourse.julialang.org/u/maajdl)\
**Post date:** [February 12, 2021, 8:43am UTC](https://discourse.julialang.org/t/how-to-check-that-a-symbol-represents-a-function/55124/3 "2021-02-12T08:43:33Z")

</div>

Thanks!  
Very nice!  
Never imagined that a module had fields … I like Julia.  
Michel

---

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [February 12, 2021, 10:33pm UTC](https://discourse.julialang.org/t/how-to-check-that-a-symbol-represents-a-function/55124/4 "2021-02-12T22:33:57Z")

</div>

alternatively

```julia
julia> isa(eval(:foo), Function)
true

```

---

<div class="post-metadata">

**Author:** ![maajdl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maajdl/32/22838_2.png) [@maajdl](https://discourse.julialang.org/u/maajdl)\
**Post date:** [February 13, 2021, 8:26pm UTC](https://discourse.julialang.org/t/how-to-check-that-a-symbol-represents-a-function/55124/5 "2021-02-13T20:26:04Z")

</div>

Thanks!
