www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - version - feature suggestions

reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Two features seems to be missing from versions:

1) reversing the condition

This C maps rather easily into D:

 #ifdef SOMETHING
 // do stuff
 #endif

as:
 version (SOMETHING) {
 // do stuff
 }

This does not:
 #ifndef SOMETHING
 // do stuff
 #endif

The current D workaround:
 version (SOMETHING)
   version = SOMETHING;
 else
   version = not_SOMETHING;
 
 version (not_SOMETHING) {
 // do stuff
 }

That quickly gets boring to write... * Suggestion: version (!SOMETHING) 2) numbered versions This code is kinda hard to "translate" :
 #define VERSION 2
 
 #if (VERSION > 2)
 // do stuff
 #endif

Current workaround in D:
 version = VERSION_1;
 version = VERSION_2;
 
 version (VERSION_2) {
 // do stuff 
 }

Again, it gets boring around 10 or so. * Suggestion: version (VERSION > 2) What do you think ? (am I missing something?) --anders PS. Another little ugliness is the casing: "Windows" versus "linux" versus "darwin" Perhaps we should ask the compilers to define *both* lowercase and CamelCase ?
Oct 18 2004
next sibling parent reply "Ivan Senji" <ivan.senji public.srce.hr> writes:
"Anders F Björklund" <afb algonet.se> wrote in message
news:cl0s4t$hs1$1 digitaldaemon.com...
 Two features seems to be missing from versions:

 1) reversing the condition

 This C maps rather easily into D:

 #ifdef SOMETHING
 // do stuff
 #endif

as:
 version (SOMETHING) {
 // do stuff
 }

This does not:
 #ifndef SOMETHING
 // do stuff
 #endif

The current D workaround:
 version (SOMETHING)
   version = SOMETHING;
 else
   version = not_SOMETHING;

 version (not_SOMETHING) {
 // do stuff
 }


Can't you write that as version(SOMETHING){} else { // do stuff }
 ...

Oct 18 2004
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Ivan Senji wrote:

The current D workaround:

version (SOMETHING)
  version = SOMETHING;
else
  version = not_SOMETHING;

version (not_SOMETHING) {
// do stuff
}


Can't you write that as version(SOMETHING){} else { // do stuff }

Hehe, yup - you are perfectly right there ! :-)
 #ifndef SOMETHING
 // do stuff
 #endif

becomes
 version (SOMETHING) {} else {
 // do stuff
 }

A little obscure, but better than my workaround... The only problem is that I now have the following:
 #ifndef SOMETHING
 // do stuff
 #else
 // do something else
 #endif

I'd prefer *not* to swap them, since it's ported C. The previous workaround still holds here, though:
 version (not_SOMETHING) {
 // do stuff
 } else {
 // do something else
 }

I can use the short workaround for most, and long for rest. --anders PS. It was for glext.h
Oct 18 2004
parent reply "Walter" <newshound digitalmars.com> writes:
"Anders F Björklund" <afb algonet.se> wrote in message
news:cl17lu$ujq$1 digitaldaemon.com...
 Can't you write that as
 version(SOMETHING){}
 else
 {
     // do stuff
 }

Hehe, yup - you are perfectly right there ! :-)

<g>. Actually, the idea here is that versions should represent something positive, like DO_THIS_FEATURE rather than "DO_NOT_DO_THIS_FEATURE".
Oct 19 2004
parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Walter wrote:

 <g>. Actually, the idea here is that versions should represent something
 positive, like DO_THIS_FEATURE rather than "DO_NOT_DO_THIS_FEATURE".

They were being used as: if (SANE) {} else { // activate ugly workaround } So it was kinda positive ? :) --anders
Oct 20 2004
prev sibling next sibling parent Sean Kelly <sean f4.ca> writes:
Anders F Björklund wrote:
 Two features seems to be missing from versions:
 
 1) reversing the condition
 
 This C maps rather easily into D:
 
 #ifdef SOMETHING
 // do stuff
 #endif

as:
 version (SOMETHING) {
 // do stuff
 }

This does not:
 #ifndef SOMETHING
 // do stuff
 #endif


It would be nice to have full expression logic in version and debug statements, assuming we don't already. Sean
Oct 19 2004
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"Anders F Björklund" <afb algonet.se> wrote in message
news:cl0s4t$hs1$1 digitaldaemon.com...
 PS. Another little ugliness is the casing:
      "Windows" versus "linux" versus "darwin"

These casings were picked to match the casings used by the C compilers on the corresponding systems.
Oct 19 2004
next sibling parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Walter wrote:

PS. Another little ugliness is the casing:
     "Windows" versus "linux" versus "darwin"

These casings were picked to match the casings used by the C compilers on the corresponding systems.

Couldn't *both* versions be defined ? As in: windows,Windows,linux,Linux,darwin,Darwin, etc. Since both Win32 and Windows are being used now ? Also suggested a "MacOSX" to David Friedman (gdc) --anders PS. It's mostly an aesthetic issue, although loader.d was broken... (as it uses version(Linux) now)
Oct 20 2004
parent reply Regan Heath <regan netwin.co.nz> writes:
On Wed, 20 Oct 2004 14:47:53 +0200, Anders F Björklund <afb algonet.se> 
wrote:
 Walter wrote:

 PS. Another little ugliness is the casing:
     "Windows" versus "linux" versus "darwin"

These casings were picked to match the casings used by the C compilers on the corresponding systems.

Couldn't *both* versions be defined ? As in: windows,Windows,linux,Linux,darwin,Darwin, etc. Since both Win32 and Windows are being used now ? Also suggested a "MacOSX" to David Friedman (gdc) --anders PS. It's mostly an aesthetic issue, although loader.d was broken... (as it uses version(Linux) now)

I'd prefer if it was simply case insensitive. I know D is case sensitive, and that we like to have consistency, but, I think this is another instance where breaking from the trend is the RightThing(TM). Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Oct 20 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
Regan Heath wrote:
 On Wed, 20 Oct 2004 14:47:53 +0200, Anders F Björklund <afb algonet.se> 

 PS. It's mostly an aesthetic issue,
      although loader.d was broken...
      (as it uses version(Linux) now)

I'd prefer if it was simply case insensitive. I know D is case sensitive, and that we like to have consistency, but, I think this is another instance where breaking from the trend is the RightThing(TM). Regan

I don't want the version identifiers to be case insensitive, but there's no good reason why the the predefined versions shouldn't be consistent. Mixed case (I prefer this)... version(Windows) version(Linux) version(MacOSX) version(Darwin) or all lowercase... version(windows) version(linux) version(macosx) Some of each hurts my eyes... version(Windows) version(linux) You might as well write, "Open the Door to let roger in." -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Oct 21 2004
parent Regan Heath <regan netwin.co.nz> writes:
On Thu, 21 Oct 2004 22:34:58 -0500, J C Calvarese <jcc7 cox.net> wrote:
 Regan Heath wrote:
 On Wed, 20 Oct 2004 14:47:53 +0200, Anders F Björklund <afb algonet.se>

 PS. It's mostly an aesthetic issue,
      although loader.d was broken...
      (as it uses version(Linux) now)

I'd prefer if it was simply case insensitive. I know D is case sensitive, and that we like to have consistency, but, I think this is another instance where breaking from the trend is the RightThing(TM). Regan

I don't want the version identifiers to be case insensitive,

Why not?
 but there's no good reason why the the predefined versions shouldn't be 
 consistent.

At least if they're consistent we don't have to guess what they are. My reasoning for making them case insensitive is that it becomes less possible for a typo to cause trouble. i.e. version (windows) version (WINDOWS) version (Windows) version (WiNdOwS) will all work. No guessing, just spell it write (joke intentional) and it will work as intended. Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Oct 21 2004
prev sibling parent Burton Radons <burton-radons smocky.com> writes:
Walter wrote:
 "Anders F Björklund" <afb algonet.se> wrote in message
 news:cl0s4t$hs1$1 digitaldaemon.com...
 
PS. Another little ugliness is the casing:
     "Windows" versus "linux" versus "darwin"

These casings were picked to match the casings used by the C compilers on the corresponding systems.

All that that means is that the C method was an ungodly mess that should be sorted out by a sensible and consistent New Way: Compiler.DigitalMars Compiler.GDC Compiler.DNET Processor.X86 Processor.AMD64 Processor.Endian.Big Processor.Endian.Little OS.Windows OS.Linux Asm.X86 None There should also be versions describing such details as what kind of calling convention is used by the compiler for D linking to reduce potential for assumptions (false assumptions are the cause of all accidents.) As it is, there is no way to prove that an asm statement is safe; therefore, they cannot be put in robust libraries.
Oct 21 2004