Thread overview | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 09, 2006 version and debug statements | ||||
---|---|---|---|---|
| ||||
i've noticed code like this: version (foo) {} else { do something... } would it be more natural to be able to write: version (!foo) { do something... } the same applies to the debug statement. thanks |
May 09, 2006 Re: version and debug statements | ||||
---|---|---|---|---|
| ||||
Posted in reply to maxter | maxter wrote: > i've noticed code like this: > > version (foo) > {} > else > { > do something... > } Usually written as: version (foo) {} else { .... } > would it be more natural to be able to write: > > version (!foo) > { > do something... > } > > the same applies to the debug statement. thanks Yes it would, and Thomas patched this in bug #2522 http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2522 But I don't think that they ever caught on with W. http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/11946 http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/11995 --anders |
May 11, 2006 Re: version and debug statements | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | Anders F Björklund wrote: > maxter wrote: > >> i've noticed code like this: >> >> version (foo) >> {} >> else >> { >> do something... >> } > > Usually written as: > version (foo) {} else > { > .... > } > Yeah, I've had to do that a few times myself; very annoying. >> would it be more natural to be able to write: >> >> version (!foo) >> { >> do something... >> } >> the same applies to the debug statement. thanks > > Yes it would, and Thomas patched this in bug #2522 http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2522 > > But I don't think that they ever caught on with W. http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/11946 http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/11995 > > --anders That's odd, given that D is more or less designed to avoid silly hacks like this... -- Daniel -- v1sw5+8Yhw5ln4+5pr6OFma8u6+7Lw4Tm6+7l6+7D a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/ |
May 11, 2006 Re: version and debug statements | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Keep | Daniel Keep wrote: >> version (foo) {} else >> { >> .... >> } > That's odd, given that D is more or less designed to avoid silly hacks > like this... Both D and W seem to be more open to suggestions now, so maybe it will be added in a future DMD version yet ? I'm still naively hoping for both of "version (Unix)" and "version (!Windows)" to be defined and legal in D. --anders |
May 11, 2006 Re: version and debug statements | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | Anders F Björklund wrote: > Daniel Keep wrote: > >>> version (foo) {} else >>> { >>> .... >>> } > >> That's odd, given that D is more or less designed to avoid silly hacks like this... > > Both D and W seem to be more open to suggestions now, > so maybe it will be added in a future DMD version yet ? > > I'm still naively hoping for both of "version (Unix)" > and "version (!Windows)" to be defined and legal in D. > > --anders Well, I'll continue to hope that at some point it grows boolean expressions in version statements like "version(BSD | Linux)", but I can live without those :) -- Daniel -- v1sw5+8Yhw5ln4+5pr6OFma8u6+7Lw4Tm6+7l6+7D a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/ |
May 11, 2006 Re: version and debug statements | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Keep | Daniel Keep wrote: > Well, I'll continue to hope that at some point it grows boolean > expressions in version statements like "version(BSD | Linux)", but I can > live without those :) Yeah, those can be hacked too. version (freebsd) version = freebsd_or_linux; version (linux) version = freebsd_or_linux; version (freebsd_or_linux) { ... } --anders PS. All platforms except Windows (and "Unix") use lowercase... http://www.prowiki.org/wiki4d/wiki.cgi?DocComments/Version |
May 11, 2006 Re: version and debug statements | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Keep | Daniel Keep wrote:
>
> Anders F Björklund wrote:
>> Daniel Keep wrote:
>>
>>>> version (foo) {} else
>>>> {
>>>> ....
>>>> }
>>> That's odd, given that D is more or less designed to avoid silly hacks
>>> like this...
>> Both D and W seem to be more open to suggestions now,
>> so maybe it will be added in a future DMD version yet ?
>>
>> I'm still naively hoping for both of "version (Unix)"
>> and "version (!Windows)" to be defined and legal in D.
>>
>> --anders
>
> Well, I'll continue to hope that at some point it grows boolean
> expressions in version statements like "version(BSD | Linux)", but I can
> live without those :)
>
> -- Daniel
Since "static if" is now legal at module scope, it's now practically a superset of "version". So it shouldn't be very complicated to move some of the functionality across. (There's a problem with using 'static if' instead of 'version' : if there's an 'import' statement bracketed by a static if, potentially you have to compile the program to find out which files are included. Obviously 'build' can't cope with that).
|
May 11, 2006 Re: version and debug statements | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Keep | "Daniel Keep" <daniel.keep.lists@gmail.com> wrote in message news:e3ul8t$ag8$2@digitaldaemon.com... > > > Anders F Björklund wrote: >> maxter wrote: >> >>> i've noticed code like this: >>> >>> version (foo) >>> {} >>> else >>> { >>> do something... >>> } >> >> Usually written as: >> version (foo) {} else >> { >> .... >> } >> > > Yeah, I've had to do that a few times myself; very annoying. > >>> would it be more natural to be able to write: >>> >>> version (!foo) >>> { >>> do something... >>> } >>> the same applies to the debug statement. thanks >> >> Yes it would, and Thomas patched this in bug #2522 http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2522 >> >> But I don't think that they ever caught on with W. http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/11946 http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/11995 >> >> --anders > > That's odd, given that D is more or less designed to avoid silly hacks like this... I agree. Having to define an empty version block is most definitely inefficient and doesn't support code readability. > > -- Daniel > > -- > > v1sw5+8Yhw5ln4+5pr6OFma8u6+7Lw4Tm6+7l6+7D a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/ |
May 11, 2006 Re: version and debug statements | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | On Thu, 11 May 2006 19:32:07 +1000, Don Clugston <dac@nospam.com.au> wrote: > Since "static if" is now legal at module scope, it's now practically a superset of "version". So it shouldn't be very complicated to move some of the functionality across. (There's a problem with using 'static if' instead of 'version' : if there's an 'import' statement bracketed by a static if, potentially you have to compile the program to find out which files are included. Obviously 'build' can't cope with that). And I don't want to make Build be a compiler too ;-) So I don't think it will ever try to execute static if statements. -- Derek Parnell Melbourne, Australia |
May 11, 2006 Re: version and debug statements | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | In article <op.s9d3gilp6b8z09@ginger>, Derek Parnell says...
>
>On Thu, 11 May 2006 19:32:07 +1000, Don Clugston <dac@nospam.com.au> wrote:
>
>
>> Since "static if" is now legal at module scope, it's now practically a superset of "version". So it shouldn't be very complicated to move some of the functionality across. (There's a problem with using 'static if' instead of 'version' : if there's an 'import' statement bracketed by a static if, potentially you have to compile the program to find out which files are included. Obviously 'build' can't cope with that).
>
>And I don't want to make Build be a compiler too ;-) So I don't think it will ever try to execute static if statements.
I'll second that.
Its also bad enough that any ddoc processing tool has to navigate version statement on top of comments and declarations. Adding the complexity of static if() would *really* overcomplicate things.
- EricAnderton at yahoo
|
Copyright © 1999-2021 by the D Language Foundation