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

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.

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


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.

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

5 Likes

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

Frequently Asked Questions · The Julia Language?

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 .

1 Like

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.

2 Likes