digitalmars.D - Fixing enum names in Phobos
- Jonathan M Davis (42/42) Jul 31 2011 Okay. Per the current naming conventions in Phobos, enum values are supp...
- %u (1/1) Jul 31 2011 How do you plan on camelCasing pure, nothrow, out, ref, etc?
- KennyTM~ (3/4) Aug 01 2011 pure_, nothrow_, out_, ref_
- Jonathan M Davis (7/13) Aug 01 2011 Yeah. Something like that. You'd have to add a prefix or a suffix to the...
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (6/19) Aug 01 2011 I may very well be biased since I come from .NET land, but I have to
- Jonathan M Davis (22/43) Aug 01 2011 o
- KennyTM~ (6/30) Aug 01 2011 In .NET (almost) everything is CapitalCamelCased :D
- Mehrdad (3/4) Aug 01 2011 lol, it's called "PascalCased". :P
- Michal Minich (4/5) Aug 01 2011 simply add exception to the camelCase rule: if word is keyword, use
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (9/51) Jul 31 2011 I'm personally a great fan of consistency and would gladly fix my code
- Jonathan M Davis (13/18) Aug 01 2011 That's a case where there's a decent argument for not camelcasing them =
Okay. Per the current naming conventions in Phobos, enum values are supposed to be camelcased just like any other variable. The enum _type_ is pascal cased just like any other user-defined type, but the values are camelcased. A number of the older parts of Phobos do not follow this convention. Ideally, this would be fixed so that Phobos can be more consistent, and for the most part, those in this newsgroup have agreed that they'd prefer to have Phobos fixed to be more consistent and put up with the temporary code breakage rather than have it permanently inconsistent. The question is whether it's worth it in this case. The enums that I'm aware of in Phobos which are not properly camelcased are: std.compiler.Vendor: DigitalMars (and the recently added GNU, LLVM, and Unknown). std.mmfile.MmFile.Mode: Read, ReadWriteNew, ReadWrite, ReadCopyOnWrite std.JSON_TYPE: STRING, INTEGER, FLOAT, OBJECT, ARRAY, TRUE, FALSE, NULL std.socket.AddressFamily: UNSPEC, UNIX, INET, IPX, APPLETALK std.socket.SocketType: STREAM, DGRAM, RAW, RDM, SEQPACKET std.socket.ProtocolType: IP, ICMP, IGMP, GGP, TCP, PUP, UDP, IDP, IPV6 std.socket.SocketShutdown: RECEIVE, SEND, BOTH std.socket.SocketFlags: NONE, OOB, PEEK, DONTROUTE std.socket.SocketOptionLevel: SOCKET, IP, ICMP, IGMP, GGP, TCP, PUP, UDP, IDP, IPV6 std.socket.OptionLevel: DEBUG, BROADCAST, REUSEADDR, LINGER, OOBINLINE, SNDBUF, RCVBUF, DONTROUTE, SENDTIMEO, RCVTIMEO, TCP_NODELAY, IPV6_UNICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP std.stream.BOM: UTF8, UTF16LE, UTF16BE, UTF32LE, UTF32BE std.system.Endian: BigEndian, LittleEndian std.traits.ParameterStorageClass: NONE, SCOPE, OUT, REF, LAZY std.traits.FunctionAttribute: NONE, PURE, NOTHROW, REF, PROPERTY, TRUSTED, SAFE std.traits.Variadic: NO, C, D, TYPESAFE std.xml.DecodeMode: NONE, LOOSE, STRICT std.xml.TagType: START, END, EMPTY So, the question is. Which, if any, should we fix to be camelcased? It will break code to fix any of these. We can't really go through a clean deprecation process on these without outright replacing the enum types themselves, which would have a nasty cascading effect through everything that uses them. The spellchecker will catch the changes easily, and so fixing any code that uses them will be easy, but it will still be annoying. So, is this temporary breakage worth the gain in consistency? And if so, for which ones? Or should we just leave them as-is? - Jonathan M Davis
Jul 31 2011
How do you plan on camelCasing pure, nothrow, out, ref, etc?
Jul 31 2011
On Aug 1, 11 13:56, %u wrote:How do you plan on camelCasing pure, nothrow, out, ref, etc?pure_, nothrow_, out_, ref_ pureAttribute, nothrowAttribute, outAttribute, refAttribute
Aug 01 2011
On Monday 01 August 2011 15:02:54 KennyTM~ wrote:On Aug 1, 11 13:56, %u wrote:Yeah. Something like that. You'd have to add a prefix or a suffix to them all. But the fact that you can't actually just camelcase them might be a good argument for leaving them as-is. If we're willing to change them though, a simple prefix or suffix shouldn't be all that big a deal - especially if it's shorter rather than longer. - Jonathan M DavisHow do you plan on camelCasing pure, nothrow, out, ref, etc?pure_, nothrow_, out_, ref_ pureAttribute, nothrowAttribute, outAttribute, refAttribute
Aug 01 2011
On 01-08-2011 09:39, Jonathan M Davis wrote:On Monday 01 August 2011 15:02:54 KennyTM~ wrote:I may very well be biased since I come from .NET land, but I have to say, camel case enum member names do seem a bit weird to me. While enum members could be argued to be fields, they certainly don't have those semantics, so maybe pascal case might not be so bad? - AlexOn Aug 1, 11 13:56, %u wrote:Yeah. Something like that. You'd have to add a prefix or a suffix to them all. But the fact that you can't actually just camelcase them might be a good argument for leaving them as-is. If we're willing to change them though, a simple prefix or suffix shouldn't be all that big a deal - especially if it's shorter rather than longer. - Jonathan M DavisHow do you plan on camelCasing pure, nothrow, out, ref, etc?pure_, nothrow_, out_, ref_ pureAttribute, nothrowAttribute, outAttribute, refAttribute
Aug 01 2011
On Monday 01 August 2011 10:00:01 Alex R=C3=B8nne Petersen wrote:On 01-08-2011 09:39, Jonathan M Davis wrote:oOn Monday 01 August 2011 15:02:54 KennyTM~ wrote:On Aug 1, 11 13:56, %u wrote:=20 Yeah. Something like that. You'd have to add a prefix or a suffix t=How do you plan on camelCasing pure, nothrow, out, ref, etc?=20 pure_, nothrow_, out_, ref_ =20 pureAttribute, nothrowAttribute, outAttribute, refAttributeothem all. But the fact that you can't actually just camelcase them might be a good argument for leaving them as-is. If we're willing t=bigchange them though, a simple prefix or suffix shouldn't be all that=uma deal - especially if it's shorter rather than longer. =20 - Jonathan M Davis=20 I may very well be biased since I come from .NET land, but I have to say, camel case enum member names do seem a bit weird to me. While en=members could be argued to be fields, they certainly don't have those=semantics, so maybe pascal case might not be so bad?Camelcasing for enum values is what was decided upon, and all of the ne= wer=20 Phobos stuff follows it. It's just some of the older stuff (primarily s= tuff which=20 was around in D1, I believe) which doesn't follow the correct naming=20= conventions for enums. We may very well decide that it's not worth fixi= ng these=20 enums to follow the correct naming conventions for Phobos, but the corr= ect=20 naming conventions have already been decided on. Enum types are pascal = cased,=20 and their values are camelcased. That's not up for discussion at this p= oint.=20 What _is_ up for discussion is whether fixing these enums to follow Pho= bos'=20 naming conventions is worth the code breakage that it will cause. - Jonathan M Davis
Aug 01 2011
On Aug 1, 11 16:00, Alex Rønne Petersen wrote:On 01-08-2011 09:39, Jonathan M Davis wrote:In .NET (almost) everything is CapitalCamelCased :D Anyway, the rule of thumb is - Things are CapitalCamelCased if they can create a type - Otherwise, they are smallLetterCamelCased Enum members aren't types, so they shouldn't be CapitalCamelCased.On Monday 01 August 2011 15:02:54 KennyTM~ wrote:I may very well be biased since I come from .NET land, but I have to say, camel case enum member names do seem a bit weird to me. While enum members could be argued to be fields, they certainly don't have those semantics, so maybe pascal case might not be so bad? - AlexOn Aug 1, 11 13:56, %u wrote:Yeah. Something like that. You'd have to add a prefix or a suffix to them all. But the fact that you can't actually just camelcase them might be a good argument for leaving them as-is. If we're willing to change them though, a simple prefix or suffix shouldn't be all that big a deal - especially if it's shorter rather than longer. - Jonathan M DavisHow do you plan on camelCasing pure, nothrow, out, ref, etc?pure_, nothrow_, out_, ref_ pureAttribute, nothrowAttribute, outAttribute, refAttribute
Aug 01 2011
On 8/1/2011 2:15 AM, KennyTM~ wrote:In .NET (almost) everything is CapitalCamelCased :Dlol, it's called "PascalCased". :P +1 for PascalCasing. It solves the keyword-ness issue.
Aug 01 2011
On Mon, 01 Aug 2011 05:56:22 +0000, %u wrote:How do you plan on camelCasing pure, nothrow, out, ref, etc?simply add exception to the camelCase rule: if word is keyword, use PascalCase. IMO, easier to remember and to the eyes than any kind of ad-hoc pre/sufix.
Aug 01 2011
On 01-08-2011 04:30, Jonathan M Davis wrote:Okay. Per the current naming conventions in Phobos, enum values are supposed to be camelcased just like any other variable. The enum _type_ is pascal cased just like any other user-defined type, but the values are camelcased. A number of the older parts of Phobos do not follow this convention. Ideally, this would be fixed so that Phobos can be more consistent, and for the most part, those in this newsgroup have agreed that they'd prefer to have Phobos fixed to be more consistent and put up with the temporary code breakage rather than have it permanently inconsistent. The question is whether it's worth it in this case. The enums that I'm aware of in Phobos which are not properly camelcased are: std.compiler.Vendor: DigitalMars (and the recently added GNU, LLVM, and Unknown). std.mmfile.MmFile.Mode: Read, ReadWriteNew, ReadWrite, ReadCopyOnWrite std.JSON_TYPE: STRING, INTEGER, FLOAT, OBJECT, ARRAY, TRUE, FALSE, NULL std.socket.AddressFamily: UNSPEC, UNIX, INET, IPX, APPLETALK std.socket.SocketType: STREAM, DGRAM, RAW, RDM, SEQPACKET std.socket.ProtocolType: IP, ICMP, IGMP, GGP, TCP, PUP, UDP, IDP, IPV6 std.socket.SocketShutdown: RECEIVE, SEND, BOTH std.socket.SocketFlags: NONE, OOB, PEEK, DONTROUTE std.socket.SocketOptionLevel: SOCKET, IP, ICMP, IGMP, GGP, TCP, PUP, UDP, IDP, IPV6 std.socket.OptionLevel: DEBUG, BROADCAST, REUSEADDR, LINGER, OOBINLINE, SNDBUF, RCVBUF, DONTROUTE, SENDTIMEO, RCVTIMEO, TCP_NODELAY, IPV6_UNICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP std.stream.BOM: UTF8, UTF16LE, UTF16BE, UTF32LE, UTF32BE std.system.Endian: BigEndian, LittleEndian std.traits.ParameterStorageClass: NONE, SCOPE, OUT, REF, LAZY std.traits.FunctionAttribute: NONE, PURE, NOTHROW, REF, PROPERTY, TRUSTED, SAFE std.traits.Variadic: NO, C, D, TYPESAFE std.xml.DecodeMode: NONE, LOOSE, STRICT std.xml.TagType: START, END, EMPTY So, the question is. Which, if any, should we fix to be camelcased? It will break code to fix any of these. We can't really go through a clean deprecation process on these without outright replacing the enum types themselves, which would have a nasty cascading effect through everything that uses them. The spellchecker will catch the changes easily, and so fixing any code that uses them will be easy, but it will still be annoying. So, is this temporary breakage worth the gain in consistency? And if so, for which ones? Or should we just leave them as-is? - Jonathan M DavisI'm personally a great fan of consistency and would gladly fix my code if it means the standard library would be cleaned up. As for std.compiler.Vendor: I'm not sure if renaming these is a good idea. On one hand, there's consistency, but on the other hand, you'd probably want actual project/product/company names like that to be spelled correctly... That's why I just followed the pascal case convention in my patches. - Alex
Jul 31 2011
On Monday 01 August 2011 08:26:26 Alex R=C3=B8nne Petersen wrote:As for std.compiler.Vendor: I'm not sure if renaming these is a good idea. On one hand, there's consistency, but on the other hand, you'd probably want actual project/product/company names like that to be spelled correctly... That's why I just followed the pascal case convention in my patches.That's a case where there's a decent argument for not camelcasing them = -=20 though Unknown should probably be changed to unknown. And since it's br= and=20 new, it wouldn't even break any code to do that. Though of course, ther= e's=20 still the issue of whether or not std.compiler should be deprecated in = favor=20 of just using core.rt.compiler. But regardless of where the enum ends u= p, the=20 naming issue is still the same. - Jonathan M Davis
Aug 01 2011