-
Notifications
You must be signed in to change notification settings - Fork 173
Access modifiers for callables and types #259
Description
Is your feature request related to a problem? Please describe.
When developing Q# libraries, it is common to introduce small functions and operations that are not intended for direct use, but which are helpful with partial application. At the moment, these functions and operations are given names starting with _ or ending with Impl, but that makes it easy to accidentally take a dependency on these functions and operations from other namespaces or compilation units.
Describe the solution you'd like
I would suggest the inclusion of an accessibility modifier attribute (or possibly multiple, depending on the level of granularity needed), paralleling the use of special-purpose keywords in other languages. In particular,
namespace Microsoft.Quantum.Core {
@Attribute()
newtype Private = Unit;
}In code that calls a @Private() function or operation from another namespace or compilation unit, a warning could be raised indicating that about a possible accidental dependency on internal implementation details.
The new accessibility modifier attributes could also be used to simplify documentation generation logic, such that no documentation is generated for @Private() callables rather than depending on name-matching (paralleling the new @Test("…") attribute).
Describe alternatives you've considered
- The current approach could continue to be used, in which the leading underscore convention is given special meaning by the compiler and documentation generation tool. This suffers the same disadvantages as relying on
*Testnames for unit testing. - New keywords (e.g.:
private) could be introduced instead of new attributes.