# How to delete a function?

**URL:** <https://discourse.julialang.org/t/how-to-delete-a-function/108422>\
**Category:** New to Julia\
**Tags:** question, functions\
**Created:** [January 6, 2024, 3:26am UTC](https://discourse.julialang.org/t/how-to-delete-a-function/108422 "2024-01-06T03:26:04Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [January 6, 2024, 6:09am UTC](https://discourse.julialang.org/t/how-to-delete-a-function/108422/5 "2024-01-06T06:09:16Z")

</div>

As said by others:

- If what you want is to make sure that the function name is not used before, or it does not exist, you can query with the function `isdefined`, or easier with the macro `@isdefined` (e.g. `@isdefined foo` to query if there is anything called `foo` in the current module`.
- If you want to delete a function (or whatever other type of object’s) name, unfortunately [you can’t](https://docs.julialang.org/en/v1/manual/faq/#How-do-I-delete-an-object-in-memory?). (There are other useful FAQs in the same page.)

The nearest thing to Matlab’s workspaces in Julia are modules. It is possible to [switch between modules in the REPL](https://docs.julialang.org/en/v1/stdlib/REPL/#Changing-the-contextual-module-which-is-active-at-the-REPL), which is the closest that you’ll get to `clear all` in Matlab (without actually deleting anything), but it’s better to adapt your workflows so that you don’t feel the need of “deleting variables”, which is unnatural in Julia.

Since you are asking several questions related to transitioning from Matlab to Julia, let me recommend you to spend some time reading some of the many resources that the community has being producing for such situations. There is a thread from a few year ago where they started to comment on this:

> [@TL;DR tips for Julia users coming from Matlab](https://discourse.julialang.org/t/tl-dr-tips-for-julia-users-coming-from-matlab/41093):
>
> While the Julia Discourse and Slack communities are incredibly helpful, the responses can lean more technical. I thought it’d be nice to collect TL;DR advice for Julia summarized in simple terms. For example, in [this thread on “why use tuples”](https://discourse.julialang.org/t/when-to-use-tuples/18675), in addition to the responses about tuples helping with type inference, it’d be nice to also have a simple “they are faster than arrays (e.g., to splat)”. Non-technical terminology is also helpful for folks like myself, who are transitioning from Matlab o…

And some other resources that might be useful too (you’ll find many more with any search engine):

[https://en.wikibooks.org/wiki/Julia\_for\_MATLAB\_Users](https://en.wikibooks.org/wiki/Julia_for_MATLAB_Users)

> **[GitHub - brenhinkeller/JuliaAdviceForMatlabProgrammers: Learning to love...](https://github.com/brenhinkeller/JuliaAdviceForMatlabProgrammers)**
>
> Learning to love dispatch-oriented programming. Contribute to brenhinkeller/JuliaAdviceForMatlabProgrammers development by creating an account on GitHub.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-delete-a-function/108422)._
