www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Predefined Version Identifier on Linux

reply Shan-yung Yang <littleshan gmail.com> writes:
Hi,

I wonder why the first letter of predefined identifier "linux" is not
uppercased. This looks inconsistent with other uppercased identifiers and makes
users confused.
Mar 28 2007
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Shan-yung Yang wrote:
 I wonder why the first letter of predefined identifier "linux" is not
uppercased. This looks inconsistent with other uppercased identifiers and makes
users confused.

It's consistent with the macro "linux" predefined by gcc on linux.
Mar 28 2007
next sibling parent reply Shan-yung Yang <littleshan gmail.com> writes:
Walter Bright Wrote:

 Shan-yung Yang wrote:
 I wonder why the first letter of predefined identifier "linux" is not
uppercased. This looks inconsistent with other uppercased identifiers and makes
users confused.

It's consistent with the macro "linux" predefined by gcc on linux.

But on windows almost all compilers use "WIN32" or "_WIN32" with all letters uppercased. Should D also use "WIN32" by this reason?
Mar 28 2007
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Shan-yung Yang wrote:
 Walter Bright Wrote:
 
 Shan-yung Yang wrote:
 I wonder why the first letter of predefined identifier "linux" is not
uppercased. This looks inconsistent with other uppercased identifiers and makes
users confused.

It's consistent with the macro "linux" predefined by gcc on linux.

But on windows almost all compilers use "WIN32" or "_WIN32" with all letters uppercased. Should D also use "WIN32" by this reason?

The corresponding one would be "_WINDOWS". But that just looks so awful :-(.
Mar 28 2007
next sibling parent Dan <murpsoft hotmail.com> writes:
Walter Bright Wrote:
 The corresponding one would be "_WINDOWS". But that just looks so awful :-(.

Thanks Walter, for not using that. Personally, I think Walter did the mostly right thing; but I understand most of us prefer Linux over windows and don't like feeling less capitalized. Don't worry. With Virtual Iron 3.5 out, Windows is practically a goner. Highly recommended.
Mar 28 2007
prev sibling parent Shan-yung Yang <littleshan gmail.com> writes:
Walter Bright Wrote:

 Shan-yung Yang wrote:
 
 But on windows almost all compilers use "WIN32" or "_WIN32" with all letters
uppercased. Should D also use "WIN32" by this reason?

The corresponding one would be "_WINDOWS". But that just looks so awful :-(.

Personally I agree with Carlos' opinion that version identifiers should be case insensitive, or there should be one single convention: either camel cased or adopting the corresponding macro in C. I'll appreciate camel case since the latter is often a mess.
Mar 29 2007
prev sibling parent reply "Carlos Smith" <carlos-smith sympatico.ca> writes:
: It's consistent with the macro "linux" predefined by gcc 
on linux.

Version identification should be case insensitive.

What is the point to make a difference between

  Linux
  linux

or

  Win32
  WIN32
  win32

Did anybody asked for this before ?
Mar 28 2007
parent reply Daniel Keep <daniel.keep.lists gmail.com> writes:
Carlos Smith wrote:
 : It's consistent with the macro "linux" predefined by gcc 
 on linux.
 
 Version identification should be case insensitive.
 
 What is the point to make a difference between
 
   Linux
   linux
 
 or
 
   Win32
   WIN32
   win32
 
 Did anybody asked for this before ?

Probably because everything else in the language is case-sensitive; having a single, non-obvious break would be a bit silly. Plus, we would *then* have people coming and asking "why are version identifiers case-insensitive: they should be case-sensitive". <joke> Now, the *real* solution to this problem is to rename all the identifiers to use l33t speak and alternating caps. This way, everyone is annoyed equally, and no one group has an advantage over the others. Sure everybody loses, but at least we all lose *equally*. </joke> <joke type="alternate" id="1"> Just look at it this way: you Linux people are better off since you don't need to use the shift key to type your platform identifier! Less key presses == more productive! </joke> <joke type="alternate" id="2"> The real reason Walter did this is because he's trying to discourage people from writing non-portable code. He probably figures that it he makes every single platform identifier different in some subtle, non-predictable manner, people will get sick of it and just write portable code in the first place. Coming soon: version( MACos_X )! </joke> Sorry. I haven't had the opportunity to annoy anyone today, and I just watched House. Baaaad combination... ;) -- Daniel -- int getRandomNumber() { return 4; // chosen by fair dice roll. // guaranteed to be random. } http://xkcd.com/ v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
Mar 28 2007
next sibling parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Daniel Keep wrote:

 The real reason Walter did this is because he's trying to discourage
 people from writing non-portable code.  He probably figures that it he
 makes every single platform identifier different in some subtle,
 non-predictable manner, people will get sick of it and just write
 portable code in the first place.

Fortunately the other platforms are all lowercase: - linux - freebsd - cygwin - mingw32 - darwin - solaris - skyos And you can use version( Unix ) for all of those...
 Coming soon: version( MACos_X )!
 </joke>
 
 Sorry.  I haven't had the opportunity to annoy anyone today, and I just
 watched House.  Baaaad combination...  ;)

There already is a version (MacOSX) in use in dAllegro. HHOS. --anders
Mar 28 2007
parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
 Fortunately the other platforms are all lowercase:
 - linux
 - freebsd
 - cygwin
 - mingw32
 - darwin
 - solaris
 - skyos
 
 And you can use version( Unix ) for all of those...

Ehrm, "mingw32" would be Windows (or Win32?) but anyway. --anders
Mar 28 2007
prev sibling parent reply "Carlos Smith" <carlos-smith sympatico.ca> writes:
: Sorry.  I haven't had the opportunity to annoy anyone 
today, and I just
: watched House.  Baaaad combination...  ;)

LoL !

GrEaT, dO yOu FeEl BeTtEr NoW ?
iF yEs, ThAn I WiLl CoNsIdEr ThIs aS mY lItTle
CoNtRiBuTiOn To BrInG jOy In ThE lIfE oF
sOmEoNe !

HaVe A nIcE dAy.
Mar 28 2007
parent Dan <murpsoft hotmail.com> writes:
Carlos Smith Wrote:
 GrEaT, dO yOu FeEl BeTtEr NoW ?
 iF yEs, ThAn I WiLl CoNsIdEr ThIs aS mY lItTle
 CoNtRiBuTiOn To BrInG jOy In ThE lIfE oF
 sOmEoNe !
 
 HaVe A nIcE dAy.

Wow dude. I didn't know you were the maintainer of *that many* Linux modules. They mostly follow convention, but it always irked me reading the source, 'cause the case rules change every other identifier. x = HOLY_HELL_IM_CAPITALIZED; x += WhatDoYouThink * iDontKnow(im_just_trying_to_read,thissource);
Mar 28 2007