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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:25:45+00:00 2026-06-10T06:25:45+00:00

This is a very elementary question about the F# class syntax. Here is a

  • 0

This is a very elementary question about the F# class syntax. Here is a little code to illustrate my problem.

type AClass() as self =
    member this.Something = printfn "Hello"

Basically from what I have read the “as self” will create a name to the current instance which can be used in the entire class (like “this” in C# or Java). But “member this.Something” will do the same thing, only that the scope is limited to the method body. I guess I can see when you would use which syntax. The “as self” one can be used if you need it in the constructor or something and you can use the other one if you dont need it in the constructor.

But why do I have to use the “member this.Something” syntax even if I used the “as self” one? Why does it give me an error if I just write “member Something”? What have I missed?

Take care,
Kerr

  • 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-10T06:25:46+00:00Added an answer on June 10, 2026 at 6:25 am

    The scope of as self is the whole class, while scope of this.Something is just an individual method. You don’t often need as self since using this.Something is adequate.

    Regarding why you need this. in member declaration, I think it’s a natural choice since in F# classes you often have let bounds and static methods as well. Having self as default would cause confusion and misuse.

    Here is an example using as self in MSDN, which is not common IMO:

    type MyClass2(dataIn) as self =
       let data = dataIn
       do
           self.PrintMessage()
       member this.PrintMessage() =
           printf "Creating MyClass2 with Data %d" data
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Windows Forms, VB application... Forgive me in advance for this very elementary question but
This is a very elemental question about object-orientated programming- so sorry in advance if
This seems like a very elementary question, but I would like to go with
This is a very elementary I realize, I have recently started working with asp.net
This very simple code: #include <iostream> using namespace std; void exec(char* option) { cout
In this very simple code example, messages get lost every once in a while.
I have this very simple jQuery function: $(.milestone-in-tree).live({ mouseenter: function() { setTimeout( $.ajax({ type:
I have this very simple button that I would like to hide <input type=button
This very well my be a SuperUser.com question, however it's directly related to my
So, this may seem very elementary for you guys but I am officially stumped.

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.