<commit_before>:orphan:

Scope and introduction
======================

This document defines the policy for applying access control modifiers and
related naming conventions for the Swift standard library and overlays.

In this document, “stdlib” refers to the core standard library and
overlays for system frameworks written in Swift.

Swift has three levels of access control --- private, internal
and public.  As currently implemented, access control is only
concerned with API-level issues, not ABI.  The stdlib does not have a stable ABI,
and is compiled in "non-resilient" mode with inlining into user code; thus, all
stdlib symbols are considered ABI and stdlib clients should be recompiled after
*any* change to the stdlib.

`public`
========

User-visible APIs should be marked public.

Unfortunately, the compiler has bugs and limitations that the stdlib
must work around by defining additional public symbols not intended
for direct consumption by users.  For example:

.. parsed-literal::

  // Workaround.
  public protocol **_Collection** { ... }

  // Symbol intended for use outside stdlib.
  public protocol Collection : **_Collection** { ... }

These symbols are hidden using the `leading underscore rule`_.

Because Swift does not yet support a notion of SPI, any implementation
details that are shared across the stdlib's various sub-modules must
also be public.  These names, too, use the `leading underscore rule`_.

To document the reason for marking symbols public, we use comments:

* symbols used in tests::

    public // @testable
    func _foo() { ... }

* symbols that are SPIs for the module X::

    public // SPI(X)
    public _foo() { ... }

`internal`
==========<commit_msg>Fix AccessControlInStdlib SPI example<commit_after>:orphan:

Scope and introduction
======================

This document defines the policy for applying access control modifiers and
related naming conventions for the Swift standard library and overlays.

In this document, “stdlib” refers to the core standard library and
overlays for system frameworks written in Swift.

Swift has three levels of access control --- private, internal
and public.  As currently implemented, access control is only
concerned with API-level issues, not ABI.  The stdlib does not have a stable ABI,
and is compiled in "non-resilient" mode with inlining into user code; thus, all
stdlib symbols are considered ABI and stdlib clients should be recompiled after
*any* change to the stdlib.

`public`
========

User-visible APIs should be marked public.

Unfortunately, the compiler has bugs and limitations that the stdlib
must work around by defining additional public symbols not intended
for direct consumption by users.  For example:

.. parsed-literal::

  // Workaround.
  public protocol **_Collection** { ... }

  // Symbol intended for use outside stdlib.
  public protocol Collection : **_Collection** { ... }

These symbols are hidden using the `leading underscore rule`_.

Because Swift does not yet support a notion of SPI, any implementation
details that are shared across the stdlib's various sub-modules must
also be public.  These names, too, use the `leading underscore rule`_.

To document the reason for marking symbols public, we use comments:

* symbols used in tests::

    public // @testable
    func _foo() { ... }

* symbols that are SPIs for the module X::

    public // SPI(X)
    func _foo() { ... }

`internal`
==========
{'fraction_non_alphanumeric': 0.08604651162790698, 'fraction_numerical': 0.0, 'mean_word_length': 4.045454545454546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1053220', 'n_tokens_mistral': 880, 'n_tokens_neox': 827, 'n_words': 459}