If in F# I have methods like:
drawBox
drawSphere
paintImage
Would they be transferred to C#, exactly the same?
If that's the case, then wouldn't it compromise the naming conventions in C#, where methods are supposed to be PascalCase?
Or should I make them PascalCase in F# as well to remedy this?
You should follow the F# Component Design Guidelines .
The notable parts are:
invalidArg
), and for the "standard collection functions" (eg List.map
). In both these cases, the function names act much like keywords in the language. Another way to slice it:
As others already pointed out, the names of compiled members are exactly the same as the names you wrote in the F# code. In general, it is a good idea to follow standard C# naming conventions when declaring classes. When declaring an F# module then you can either use camelCase
(especially for modules that are intended for F# users) or PascalCase
if you want to use them from C#.
Also, there is one trick that you can use (this is used in the F# core library for functions like List.map
that are actually compiled as List.Map
). You can use the CompiledName
attribute to specify the name in the compiled version:
module Bar =
[<CompiledName("Foo")>]
let foo a = a + 1
It is probably better to use a unified naming convention, but if you want to keep a nice short name for F# users and standard .NET name for C# users, this is an interesting option.
type methods names will be the same both in F# and C#. if you want PascalCase in C# - you should use this naming convention in F#, the same with camelCase.
Naming conventions are for humans. Compilers and runtimes really don't care if every variable name is entirely unreadable, they'll still work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.