# How to run a Julia script in "release-mode"?

**URL:** <https://discourse.julialang.org/t/how-to-run-a-julia-script-in-release-mode/16091>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 9, 2018, 11:15pm UTC](https://discourse.julialang.org/t/how-to-run-a-julia-script-in-release-mode/16091 "2018-10-09T23:15:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [October 9, 2018, 11:15pm UTC](https://discourse.julialang.org/t/how-to-run-a-julia-script-in-release-mode/16091/1 "2018-10-09T23:15:45Z")

</div>

e.g I have several Julia functions with a custom check

```julia
function foo(x)
   check_greater_than(0, x)
   # do something
end

```

What is the canonical way to remove the check globally? I know one way to do it, is to define the check function as

```julia
function check_greater_than(b, x)
   if !haskey(ENV, "RELEASE")
      x > b || error("not greater than $b")
   end
   true
end

```

Is there any compiler option like `--release=true`? or will there be such a compiler option? And is it possible to use `--check-bounds=no`?

---

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [October 9, 2018, 11:20pm UTC](https://discourse.julialang.org/t/how-to-run-a-julia-script-in-release-mode/16091/2 "2018-10-09T23:20:42Z")

</div>

Ok, I find it…

```julia
@macroexpand @boundscheck check_function(x)

quote
  if Expr(:boundscheck)
      check_function(x)
  end
end

```

Err… will it be better to have a similar `release` option for the compiler? So things like `@assert` can be removed if someone want to run as a release version.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 10, 2018, 12:31am UTC](https://discourse.julialang.org/t/how-to-run-a-julia-script-in-release-mode/16091/3 "2018-10-10T00:31:41Z")

</div>

Ref [https://github.com/JuliaLang/julia/pull/25576](https://github.com/JuliaLang/julia/pull/25576).

Note that `@assert` is documented that it might be optimized away in future Julias at some optimization level.
