hubFS: THE place for F#

. . . are you on The Hub?
Welcome to hubFS: THE place for F# Sign in | Join | Help
in Search

F# Naming Convention

Last post 09-10-2008, 6:26 by felixmar. 12 replies.
Sort Posts: Previous Next
  •  11-20-2007, 1:55 4090

    F# Naming Convention

    Hello,
    Is there a "standard" naming convention for F#? Should the code follow the .NET naming convention or the OCaml or neither...

  •  11-20-2007, 2:27 4092 in reply to 4090

    Re: F# Naming Convention

    There is a document about naming conventions at Don Syme's WebLog: http://blogs.msdn.com/dsyme/archive/2006/12/18/DraftChaptersUpdateDec2006.aspx //Huusom
  •  11-20-2007, 2:48 4097 in reply to 4092

    Re: F# Naming Convention

    Yep, its kinda of a mixture of .NET and ocaml, tending more towards .NET. The biggest move away from ocaml is that F# tries to avoid underscores in identifier names, and I think the lack of underscores generally improves the readablity of the code. But I guess thats just my personal taste.
    Robert Pickering, MVP
    http://strangelights.com
  •  11-20-2007, 11:25 4105 in reply to 4097

    Re: F# Naming Convention

    Thanks, guys!

    I've read the document... the usage of the mixture syntax is much clearer now...

  •  07-29-2008, 1:58 6461 in reply to 4097

    Re: F# Naming Convention

    Will the rest of core library eventually get a Camel casing convention? As I find it highly inelegant to see underscore and Camel mixed together.
    I even see this mix within the same module like List.sumByFloat and List.fold_left
  •  07-30-2008, 16:54 6481 in reply to 6461

    Re: F# Naming Convention

    Hi,

    We've been looking at this issue and will be making some cleanup here in the F# CTP, especially for the inconsistencies like the one you mention.

    Kind regards

    don

  •  07-31-2008, 19:13 6496 in reply to 6481

    Re: F# Naming Convention

    dsyme:

    Hi,

    We've been looking at this issue and will be making some cleanup here in the F# CTP, especially for the inconsistencies like the one you mention.

    Kind regards

    don



    Thanks, so will that mean fold_left will become foldLeft ?
  •  08-08-2008, 10:30 6550 in reply to 6496

    Re: F# Naming Convention

    Associat0r:

    Thanks, so will that mean fold_left will become foldLeft ?

    I hope it becomes foldl as in Haskell :-)

  •  09-09-2008, 0:30 6987 in reply to 6550

    Re: F# Naming Convention

    So... the CTP is out... what about the naming conventions? I'm struggling with my boss right now to use the lowercase-Ocaml-like.

    :-)

    www.diegoeche.blogspot.com
  •  09-10-2008, 4:52 7020 in reply to 6550

    Re: F# Naming Convention

    I don't hope so. :)

    I see a tendency of functional programmers to use abbreviated names all the time; I guess this somehow derives from the higher terseness of functional syntax in general and a historical acceptance for abbreviations.

    While over time there seems to have been achieved some common sense about using meaningful, unabbreviated names for functions/methods/variables and all the like (though sometimes a bit overboarding), the area of functional programming does not seem to have adapted that.

    IMHO, some the "typical" function names to be found in languages as LISP, Haskell, Ocaml, aso. are horrible. While admirably terse for the knowing wizard, they have to be learned by the beginners, who, in most cases, won't be able to guess the meaning of a function by it's name. I have to admit, though, that there are enough functions, where I could not think of a name that would truly describe what the function does - higher order functions, like map and fold_left are good examples.

    Some renamings (mostly de-abbreviations) I would suggest to make life easier for beginners might be:
    • fst -> first
    • snd -> second
    • hd -> head
    • tl -> tail
    • mem -> contains
    • assoc -> associate
    • ...
    I know how this would upset the community of traditional functional programmers, and that this would be an all too great change to the library to really consider doing that, but looking from the perspective of a C#-convert, I guess I would shake my head at the sight of such names, and I do: my personal all-time-favourite is the "assq"-function.
  •  09-10-2008, 5:20 7023 in reply to 6496

    Re: F# Naming Convention

    I'm hoping for "FoldLeft" since that would follow the conventions of general .NET Framework.
  •  09-10-2008, 5:23 7025 in reply to 7023

    Re: F# Naming Convention

    One things for sure - I don't think everybody's going happy whatever conventions finally get chosen :)
    Robert Pickering, MVP
    http://strangelights.com
  •  09-10-2008, 6:26 7028 in reply to 7025

    Re: F# Naming Convention

    I personally have no preference for camelcase or underscore style, but a mixture of the two styles is not nice imo. For F# the logical choice would be to use camelcase everywhere.
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems