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 7165407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:14:03+00:00 2026-05-28T14:14:03+00:00

Is the reason F# doesn’t support nested classes technical, stylistic, arbitrary? Glancing over the

  • 0

Is the reason F# doesn’t support nested classes technical, stylistic, arbitrary?

Glancing over the BCL in Reflector, nested classes are used for enumerators, DynamicMetaObjects, and probably a few other things.

That piqued my curiosity about F# not having this feature. I’m aware that there are other ways to do the same thing. I’m mostly curious.

  • 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-05-28T14:14:04+00:00Added an answer on May 28, 2026 at 2:14 pm

    I suppose nested classes were not a core feature of the .NET object model and it was simply dropped to save the resources. There may be some technical difficulties (i.e. with visibility or with recursive type definitions), but I don’t think that would be a major problem.

    For many cases where one would use nested classes in C#, such as iterators, you can nicely use object expressions, so I guess they are in some ways replacement for nested classes:

    type Collection() =
      member x.GetEnumerator() = 
        let n = ref 0
        { new IEnumerator with
            member x.Current = box n.Value
            member x.MoveNext() = incr n; true
            member x.Reset() = n := 0 }
    

    Although this is quite similar to nested classes, it isn’t compiled as nested class and the body of an object expression cannot access private members of Collection. I guess supporting this would complicate compilation of expressions a bit, because object expressions can appear outside of a class context…

    Actually, it is possible to access private members from object expression, although the code still isn’t compiled as a nested class. See comments for details.

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

Sidebar

Related Questions

Is there a reason MySQL doesn't support FULL OUTER JOINS? I've tried full outer
This used to work, but for some reason it doesn't anymore. I use a
For some reason chrome doesn't support document.domain any more and spits out an error
For some reason Eclipse doesn't remember source lookup path for some java projects, and
This should be a very basic design question, but for some reason it doesn't
I've got model that use ExtendAssociations , but for some reason deleteHABTM doesn't seem
For some reason the following doesn't crash like my program does, but I'm pretty
For some reason it looks like constructor delegation doesn't work in the following snippet:
Is there a reason why this query doesn't work? The following query will work
StructureMap doesn't like passing in Nullable types as constructor arguments. Is there a reason

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.