Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not an expert with FSI, but some experimentation suggests that namespaces are only supported by <code>#load</code> declarations (not via typical interactions - sending a namespace declaration group to VFSI via Alt-Enter does not work), and that different interactions contribute different 'instances'. For example, with the code file</p> <pre><code>namespace Foo type Bar() = member this.Qux() = printfn "hi" namespace Other type Whatever() = class end namespace Foo module M = let bar = new Bar() bar.Qux() </code></pre> <p>if I <code>#load</code> it more than once I get e.g.</p> <pre><code>&gt; [Loading C:\Program.fs] hi namespace FSI_0002.Foo type Bar = class new : unit -&gt; Bar member Qux : unit -&gt; unit end namespace FSI_0002.Other type Whatever = class new : unit -&gt; Whatever end namespace FSI_0002.Foo val bar : Bar &gt; #load @"C:\Program.fs";; &gt; [Loading C:\Program.fs] hi namespace FSI_0003.Foo type Bar = class new : unit -&gt; Bar member Qux : unit -&gt; unit end namespace FSI_0003.Other type Whatever = class new : unit -&gt; Whatever end namespace FSI_0003.Foo val bar : Bar &gt; new Foo.Bar();; &gt; val it : Foo.Bar = FSI_0003.Foo.Bar </code></pre> <p>Note that it seems the FSI_0003.Foo.Bar shadowed the FSI_0002 version.</p> <p>So I'm thinking the part of the F# spec that says</p> <blockquote> <p>Within a namespace declaration group, the namespace itself is implicitly opened if any preceding namespace declaration groups or referenced assemblies contribute to this namespace, e.g. </p> <pre><code>namespace MyCompany.MyLibrary module Values1 = let x = 1 namespace MyCompany.MyLibrary // Implicit open of MyCompany.MyLibrary bringing Values1 into scope module Values2 = let x = Values1.x </code></pre> <p>However this only opens the namespace as constituted by preceding namespace declaration groups.</p> </blockquote> <p>Does not interact with FSI, given FSI's limited understanding of namespaces. Specifically, I expect that the 'second #load' from your example opens e.g. <code>FSI_000N+1</code>'s version of the namespace, whereas the prior code was in <code>FSI_000N</code>. Which maybe-explains why the explicit <code>open</code> interaction fixes it; you bring the existing, unshadowed <code>FSI_000N</code> stuff up to the top level before trying to (implicitly) reference it later.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload