views:

104

answers:

3

I searched here and on the net but no answer.

The reason I ask is, since F# conventions seems like they favor noncapital letters, using BCL types with Pascal conventions look weird in F#, as in:

let stringD = String.Join(" ",[| stringA; stringB |])

Seems like it would be more in the spirit of F# like this:

let stringD = string.join(" ",[| stringA; stringB |])
+1  A: 

Surprisingly, the F# Language Specification does not explicitly mention case-sensitivity, but does refer to using different casing for intrinsics/language and user-defined type parameters (5.1.2)

Whilst my experience with F# is limited (beyond Hello World-style apps) I would assume that string.join does not bind to String.Join.

David
Ok I can understand Join being not found in String, but in C# string or String works to access it's members. Why doesn't this work in F#? Is this some IDE magic behind the covers for C#?
Joan Venge
In C#, 'string' is a keyword that means 'System.String'. In F#, 'string' is the name of a function as well as a type alias, and not a keyword.
Brian
+2  A: 

Yes, F# is case-sensitive

let stringD = string.join(" ",[| stringA; stringB |])

Will not work.

Enemy of the State
+4  A: 

Ok, a few things.

First, F# is case-sensitive.

Second, the F# conventions for naming are described in the F# Component Design Guidelines . Briefly, let-bound members inside F# modules use camelCase, but all .NET OO constructs use PascalCase. This is true throughout the F# library.

Finally, in F# string is not a keyword, rather it is both the name of a type abbreviation (for System.String) and the name of a function (that converts to a string). In the expression context of string.Join, the function name takes precedence, which is why string.Join does not work. And because of case-sensitivity, System.String.join would never work (unless e.g. you added an extension member).

Brian
Thanks amazing answer. Looks like I will be asking you a lot of F# questions here if you don't mind :O
Joan Venge