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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:30:58+00:00 2026-05-23T15:30:58+00:00

I got a strange behavior when I used F#. When I use let binding

  • 0

I got a strange behavior when I used F#.
When I use let binding in a module, and if the value is created from a constructor, then it’s uninitialized when used outside. (I used it from C# using ModuleName.s2 or ModuleName.f())

//in a module
let s1 = "1" //normal
let s2 = new String('i', 5) //null

let f () =
    s2.Equals("something") //Exception

Is this a normal behavior? Thanks in advance.

EDIT:
For the purpose of debugging, I choose to compile it as an executable. This may be the problem as other people pointed out.

  • 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-23T15:30:58+00:00Added an answer on May 23, 2026 at 3:30 pm

    In an F# library, modules are initialized via static constructors which ensure that initialization occurs prior to any of the module’s values being used. By contrast, in an F# executable, this initialization is performed in the application’s entry point. This means that if another assembly references the F# application (regardless of the language the other application is written in), the initialization code won’t be run.

    UPDATE

    Brian pointed me to this part of the spec, which indicates that this is the expected behavior.

    It looks like one workaround would be to provide an explicit entry point, like this:

    [<EntryPoint>]
    let main _ =
        0
    

    You can then call this main method from your C# app to ensure that the module’s contents are properly initialized.

    UPDATE 2

    I was misreading the spec – you do not need to actually call the explicit entry point from the referencing assembly. Its mere presence will cause the initialization to occur correctly.

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

Sidebar

Related Questions

I got a strange behavior from the mail function in php here is the
Got a strange problem created a little stored proc which need to execute a
I got a strange compilation error when I followed the MSDN document to use
I've got a strange problem. Let me first describe my situation: Webserver01 (Webapplication, SQL,
i've got a strange behavior or autospec. On autospec run i see in console
I have a strange behavior of Rails 3.0.10. Got this application controller: app/controllers/application_controller.rb require
I've got a C++ gui project exhibiting some strange behavior. On my machine, the
I got a strange behavior with an Eclipse installation: Even though all update sites
I've got a quite strange startup behavior for my application. The first time the
I've got extremely strange behavior on one of my pages. I was able to

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.