Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9200869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:51:59+00:00 2026-06-17T22:51:59+00:00

I just noticed a rather counter intuitive behaviour when the field part of an

  • 0

I just noticed a rather counter intuitive behaviour when the field part of an F# record is declared private. (This is related to Is it possible to make a field of a record private? or to make a member of record private?)

In this example…

type MyRec = 
    private  // Fields declared private, or at least I thought so.
        { a : int
          b : int }
    member x.A = x.a
    member private x.Both = x.a + x.b
    static member CreateMyRec(a, b) = { a = a; b = b }

let foo = MyRec.CreateMyRec(1,2)
let bar = foo.a     // No error. Huh?
let baz = foo.Both  // Error: not accessible.

…the private member Both is inaccessible outside the type declaration scope, as is expected. However, the field a is accessible.

If you put MyRec in a module, the fields become private to that module. That’s how you’d expect a top level declaration in the module to behave, but I expected that anything declared private within a type, would be private to that type, not to its enclosing module.

Is this behaviour actually weird, or am I missing something in my reasoning here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:52:00+00:00Added an answer on June 17, 2026 at 10:52 pm

    As far as I can tell, this is an under-documented feature. But, section 10.5 of the spec, Accessibility Annotations, states:

    private on a type, module, or type representation in a module means “private to the module.”

    “type representation” being the part relevant to record fields.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just noticed in ByteArrayOutputStream , the toByteArray() is declared as, public synchronized byte toByteArray()[];
I just noticed this about a week ago. I'm storing data about the current
I just noticed a new term pimpl idiom, what's the difference between this idiom
I just noticed that the gMap view tools are displaying…rather unusually. Their regions still
I just noticed a rather severe bug in my iPhone/iPad app: I have a
I am creating a responsive website, and have just noticed a strange behaviour in
Just getting my hands around intent filters, and I've noticed a rather hit and
hi im recurringly updating this map and i noticed its acumulating items rather than
I have noticed a rather strange behaviour in IE. I have a HTML form
I just noticed that moving the mouse cursor across a tooltip does not seem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.