Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 18, 2004 version - feature suggestions | ||||
---|---|---|---|---|
| ||||
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 ? |
October 18, 2004 Re: version - feature suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | "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 } > ... |
October 18, 2004 Re: version - feature suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ivan Senji | 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 |
October 19, 2004 Re: version - feature suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | 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
|
October 20, 2004 Re: version - feature suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | "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. |
October 20, 2004 Re: version - feature suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | "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". |
October 20, 2004 Re: version - feature suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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
|
October 20, 2004 Re: version - feature suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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) |
October 20, 2004 Re: version - feature suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | 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/ |
October 21, 2004 Re: version - feature suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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.
|
Copyright © 1999-2021 by the D Language Foundation