# Is \`Base.@constprop\` strictly for internal usage?

**URL:** https://discourse.julialang.org/t/is-base-constprop-strictly-for-internal-usage/89273
**Category:** Internals & Design
**Tags:** constant-propagation
**Created:** [October 26, 2022, 6:50am UTC](https://discourse.julialang.org/t/is-base-constprop-strictly-for-internal-usage/89273 "2022-10-26T06:50:01Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)
#### Post date: [October 26, 2022, 6:50am UTC](https://discourse.julialang.org/t/is-base-constprop-strictly-for-internal-usage/89273/1 "2022-10-26T06:50:01Z")

</div>

Is it likely to become a part of the public API in the future? Or is this strictly for internal use, and package developers are discouraged from using it?

This often helps with type inference, so it would be great to have the possibility of using it in packages, with some stability guarantee.

---

<div class="post-metadata">

### Author: ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)
#### Post date: [October 26, 2022, 7:13am UTC](https://discourse.julialang.org/t/is-base-constprop-strictly-for-internal-usage/89273/2 "2022-10-26T07:13:04Z")

</div>

It’s documented, which makes it public, no?

```julia

help?> Base.@constprop
  @constprop setting ex

  @constprop controls the mode of interprocedural constant propagation for the annotated function. Two settings are
  supported:

    • @constprop :aggressive ex: apply constant propagation aggressively. For a method where the return type
       depends on the value of the arguments, this can yield improved inference results at the cost of
       additional compile time.

    • @constprop :none ex: disable constant propagation. This can reduce compile times for functions that
       Julia might otherwise deem worthy of constant-propagation. Common cases are for functions with Bool- or
       Symbol-valued arguments or keyword arguments.

```

---

<div class="post-metadata">

### Author: ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)
#### Post date: [October 26, 2022, 7:26am UTC](https://discourse.julialang.org/t/is-base-constprop-strictly-for-internal-usage/89273/3 "2022-10-26T07:26:07Z")

</div>

I think having a docstring isn’t enough. Only when something is listed in the documentation does it become public.

---

<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: [October 26, 2022, 1:25pm UTC](https://discourse.julialang.org/t/is-base-constprop-strictly-for-internal-usage/89273/4 "2022-10-26T13:25:24Z")

</div>

no. `Base.@pure` and `Base.@assume_effects` also “documented”, developers need docs too

---

<div class="post-metadata">

### Author: ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)
#### Post date: [October 26, 2022, 1:40pm UTC](https://discourse.julialang.org/t/is-base-constprop-strictly-for-internal-usage/89273/5 "2022-10-26T13:40:26Z")

</div>

> [@jar1](#):
>
> It’s documented, which makes it public, no?

[Frequently Asked Questions · The Julia Language](https://docs.julialang.org/en/v1/manual/faq/#How-does-Julia-define-its-public-API)?

According to that section of the FAQ:

> Functions, types, and constants are not part of the public API if they are not included in the documentation, _even if they have docstrings_ .

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [October 26, 2022, 1:43pm UTC](https://discourse.julialang.org/t/is-base-constprop-strictly-for-internal-usage/89273/6 "2022-10-26T13:43:34Z")

</div>

I think the answer here is that for unexported functions like this, we aren’t willing to make as strong guarantees as we do for exported and documented ones, but if something like this becomes widely used in the ecosystem, we aren’t just going to break everything without consideration for the consequences. But if you write code that uses things like `Base.@pure` and `Base.@constprop` then you should be prepared that at some point, with due warning, you might have to change your code.
