zzarchive-VisualFSharpPowerTools icon indicating copy to clipboard operation
zzarchive-VisualFSharpPowerTools copied to clipboard

Open namespace/module and fully-qualified name?

Open OkayX6 opened this issue 10 years ago • 4 comments
trafficstars

Hey guys,

I noticed something lately. Let's say User is defined in Namespace.ModuleB, and my cursor is located at $

module Namespace.ModuleA

let f (u: $User) = ()

Then I am suggested to add open ModuleB instead of open Namespace.ModuleB. Shouldn't we prefer to use the fully qualified name by default, so as to avoid potential ambiguities?

OkayX6 avatar Sep 30 '15 14:09 OkayX6

Yes, fully qualified names seem better.

I don't recall why we use short names; maybe @vasily-kirichenko remembers the reason :-).

dungpa avatar Sep 30 '15 17:09 dungpa

I do not remember either :) It seems to be the right thing though:

namespace My.Long.Name.Space.Here

module A = let foo x = x
module B = 
    open A
    let x = foo 1

Do you think that the following is better?

namespace My.Long.Name.Space.Here

module A = let foo x = x
module B = 
    open My.Long.Name.Space.Here.A
    let x = foo 1

vasily-kirichenko avatar Sep 30 '15 17:09 vasily-kirichenko

Can we easily distinguish between 'top level modules' (1 module for the entire file) vs explicit modules like in your example?

OkayX6 avatar Sep 30 '15 18:09 OkayX6

I think using open A might be wrong in some cases if there are multiple A modules from different namespaces. But we don't yet see any bug related to this; so keeping short names is good because it is aesthetically pleasing.

dungpa avatar Sep 30 '15 20:09 dungpa