Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-10 Thread Zekereth via Digitalmars-d-learn
So I was just testing some code and couldn't figure out why it 
wasn't working. My version block looked like this:


version(Linux)
{
...
}

Looking at the list(unless I'm missing something) Linux is the 
only OS that is lowercase. I'm guessing most people use Posix 
instead and never encounter this problem.


Regard,
Zekereth


Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-10 Thread Mike Parker via Digitalmars-d-learn

On Sunday, 10 April 2016 at 22:03:54 UTC, Zekereth wrote:
So I was just testing some code and couldn't figure out why it 
wasn't working. My version block looked like this:


version(Linux)
{
...
}

Looking at the list(unless I'm missing something) Linux is the 
only OS that is lowercase. I'm guessing most people use Posix 
instead and never encounter this problem.




It's an artifact of history. When this was first introduced, 
Walter's intent was to match the casing used in gcc preprocessor 
definitions. Since that time, we've standardized on 
capitalization for everything, but 'linux' lives on. I would like 
to see 'Linux' introduced for consistency and to avoid errors 
like yours (a bug lived in Phobos for a long time because of 
this) while maintaining 'linux' for backwards compatibility.


Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-10 Thread Ali Çehreli via Digitalmars-d-learn

On 04/10/2016 03:03 PM, Zekereth wrote:

So I was just testing some code and couldn't figure out why it wasn't
working. My version block looked like this:

version(Linux)
{
...
}

Looking at the list(unless I'm missing something) Linux is the only OS
that is lowercase. I'm guessing most people use Posix instead and never
encounter this problem.

Regard,
Zekereth


As a workaround, you can set version to Linux yourself:

version (linux) {
version = Linux;
}

void main() {
version (Linux) {
import std.stdio;
writeln("Linux worked!");
}
}



Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-10 Thread Zekereth via Digitalmars-d-learn

On Monday, 11 April 2016 at 00:51:19 UTC, Mike Parker wrote:
It's an artifact of history. When this was first introduced, 
Walter's intent was to match the casing used in gcc 
preprocessor definitions. Since that time, we've standardized 
on capitalization for everything, but 'linux' lives on. I would 
like to see 'Linux' introduced for consistency and to avoid 
errors like yours (a bug lived in Phobos for a long time 
because of this) while maintaining 'linux' for backwards 
compatibility.


Thanks, that makes sense. It would be nice if Linux could be 
introduced. I'll just have to remember from now on. Thanks again!


Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-10 Thread Zekereth via Digitalmars-d-learn

On Monday, 11 April 2016 at 01:15:27 UTC, Ali Çehreli wrote:

As a workaround, you can set version to Linux yourself:

version (linux) {
version = Linux;
}

void main() {
version (Linux) {
import std.stdio;
writeln("Linux worked!");
}
}


That's interesting that will help. Thanks for that!


Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-11 Thread marcpmichel via Digitalmars-d-learn

On Sunday, 10 April 2016 at 22:03:54 UTC, Zekereth wrote:
Looking at the list(unless I'm missing something) Linux is the 
only OS that is lowercase.


Is it because Linux is not an OS ? :p



Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-11 Thread Brian Schott via Digitalmars-d-learn

On Monday, 11 April 2016 at 23:01:08 UTC, marcpmichel wrote:

Is it because Linux is not an OS ? :p


I gnu somebody would bring that up.



Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-11 Thread Zekereth via Digitalmars-d-learn

On Tuesday, 12 April 2016 at 01:32:02 UTC, Brian Schott wrote:

On Monday, 11 April 2016 at 23:01:08 UTC, marcpmichel wrote:

Is it because Linux is not an OS ? :p


I gnu somebody would bring that up.


/sigh so did I.


Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-12 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/10/16 9:19 PM, Zekereth wrote:

On Monday, 11 April 2016 at 01:15:27 UTC, Ali Çehreli wrote:

As a workaround, you can set version to Linux yourself:

version (linux) {
version = Linux;
}

void main() {
version (Linux) {
import std.stdio;
writeln("Linux worked!");
}
}


That's interesting that will help. Thanks for that!


I highly recommend not to do this. New version assignments do not live 
outside the module, so you have to do this in EVERY module you want to 
use it.


Better to pass on the command line. Even better to just use the standard 
version identifier :)


-Steve


Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-12 Thread Joseph Rushton Wakeling via Digitalmars-d-learn

On Tuesday, 12 April 2016 at 01:32:02 UTC, Brian Schott wrote:

On Monday, 11 April 2016 at 23:01:08 UTC, marcpmichel wrote:

Is it because Linux is not an OS ? :p


I gnu somebody would bring that up.


There's actually a serious point here, though -- as D is ported 
to other platforms and architectures, it's going to wind up being 
used to target environments that use a Linux kernel but are not 
GNU.  Conversely, there may also be systems that are GNU but not 
Linux (e.g. the recent proposal for an Ubuntu flavour based on 
the FreeBSD kernel).


Are druntime and phobos ready to deal with those kinds of 
eventuality?


Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 12, 2016 17:22:05 Joseph Rushton Wakeling via Digitalmars-d-
learn wrote:
> On Tuesday, 12 April 2016 at 01:32:02 UTC, Brian Schott wrote:
> > On Monday, 11 April 2016 at 23:01:08 UTC, marcpmichel wrote:
> >> Is it because Linux is not an OS ? :p
> >
> > I gnu somebody would bring that up.
>
> There's actually a serious point here, though -- as D is ported
> to other platforms and architectures, it's going to wind up being
> used to target environments that use a Linux kernel but are not
> GNU.  Conversely, there may also be systems that are GNU but not
> Linux (e.g. the recent proposal for an Ubuntu flavour based on
> the FreeBSD kernel).
>
> Are druntime and phobos ready to deal with those kinds of
> eventuality?

Well, work has been done to make it so that different runtimes will work -
e.g. there's a CRuntime_Glibc and a CRuntime_Bionic. So, druntime is a lot
better off than just linux vs FreeBSD vs whatever. But it wouldn't surprise
me in the least if someone using something like Debian GNU/kFreeBSD would
find some problems with what we currently have.

- Jonathan M Davis



Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-12 Thread Joseph Rushton Wakeling via Digitalmars-d-learn

On Tuesday, 12 April 2016 at 18:23:25 UTC, Jonathan M Davis wrote:
Well, work has been done to make it so that different runtimes 
will work - e.g. there's a CRuntime_Glibc and a CRuntime_Bionic.


That's pretty cool.  Was that a result of the recent Android 
porting work, or was it a longer-standing division?


 So, druntime is a lot better off than just 
linux vs FreeBSD vs whatever. But it wouldn't surprise me in 
the least if someone using something like Debian GNU/kFreeBSD 
would find some problems with what we currently have.


Ah, fun stuff :-)

BTW, glad to see you will be making it to DConf -- looking 
forward to catching up with you!


Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 12, 2016 19:15:33 Joseph Rushton Wakeling via Digitalmars-d-
learn wrote:
> On Tuesday, 12 April 2016 at 18:23:25 UTC, Jonathan M Davis wrote:
> > Well, work has been done to make it so that different runtimes
> > will work - e.g. there's a CRuntime_Glibc and a CRuntime_Bionic.
>
> That's pretty cool.  Was that a result of the recent Android
> porting work, or was it a longer-standing division?

I believe that some of the LDC guys in particular (and maybe GDC guys too)
have been adding stuff like that over time to support the various platforms
that they support, though Bionic is specifically Android if I understand
correctly, and I think that it was spurred adding the Glibc version
specifically. IIRC, the other major divide like that is Digital Mars vs
Microsoft for the Windows C runtime, and I think that the addition of 64-bit
support to Windows is what ultimately spurred that one on.

> >  So, druntime is a lot better off than just
> >
> > linux vs FreeBSD vs whatever. But it wouldn't surprise me in
> > the least if someone using something like Debian GNU/kFreeBSD
> > would find some problems with what we currently have.
>
> Ah, fun stuff :-)
>
> BTW, glad to see you will be making it to DConf -- looking
> forward to catching up with you!

:)

- Jonathan M Davis