# ANN: ToggleableAsserts.jl

**URL:** <https://discourse.julialang.org/t/ann-toggleableasserts-jl/31291>\
**Category:** Package Announcements\
**Created:** [November 20, 2019, 1:58am UTC](https://discourse.julialang.org/t/ann-toggleableasserts-jl/31291 "2019-11-20T01:58:17Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [November 21, 2019, 2:47am UTC](https://discourse.julialang.org/t/ann-toggleableasserts-jl/31291/11 "2019-11-21T02:47:48Z")

</div>

As far as I can tell, there’s no need for `@toggle` to be a macro–it can just be a function:

```julia
function toggle(enable::Bool)
    lock(toggle_lock) do
        @eval ToggleableAsserts assert_toggle() = $enable
        on_or_off = enable ? "on." : "off."
        @info "Toggleable asserts turned "*on_or_off
    end
end

```

There’s nothing _wrong_ with using a macro, but it’s an unnecessary layer of complexity.

---

_[View the full topic](https://discourse.julialang.org/t/ann-toggleableasserts-jl/31291)._
