I suggest we ...

Restrict "private" for items in namespaces to mean "private to the namespace declaration group" #43

For F# 2.x-4.0, as discussed in thie GitHub thread (https://github.com/Microsoft/visualfsharp/issues/43#issuecomment-70650925), a "private" module or type in a namespace is actually accessible from anywhere in that assembly contributing to the same namespace.

The suggestion is to emit a warning when such an item is accessed from outside the immediate namespace declaration group in which it is declared. For example, we would give a warning if it is accessed from another file in the same namespace in the same assembly.

4 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Don Syme shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Bryan Edds commented  ·   ·  Flag as inappropriate

        To help support abstract data types as explained here - https://vimeo.com/128464151 - and as discussed in a bug report here - https://github.com/Microsoft/visualfsharp/issues/984

        I propose that we add one exception to the proposed rule, rendering it -

        "Restrict "private" for items in namespaces to mean "private to the namespace declaration group" [except where functions are defined in a module with the same name as the type and in the same namespace.]"

        We can create module with the same name as the type in namespace by using the [<CompilationRepresentation (CompilationRepresentationFlags.ModuleSuffix)>] attribute on the module, which is a common technique in F#.

        This may seem like a minor exception, but it will keep from breaking code that heavily uses the above abstract data type style, such as here - https://github.com/bryanedds/Prime

        - and here - https://github.com/bryanedds/NuGameEngine

      F# Language

      Feedback and Knowledge Base