Thread overview
Dependent version assignments only conditionally work (DMD 0.121)
Apr 18, 2005
Burton Radons
Apr 18, 2005
Thomas Kuehne
Apr 19, 2005
Walter
Apr 19, 2005
Thomas Kuehne
Apr 19, 2005
Burton Radons
April 18, 2005
This code succeeds compilation:

   version (b) illegal declaration;
   version (a) version = b;
   version = a;

However, it should fail because version "a" should be defined, then version "b", then expanding the illegal declaration.  This correctly fails:

   version (b) illegal declaration;
   version = a;
   version (a) version = b;

The compiler is only doing one pass through the declarations to find versions to assign; instead it should restart the loop anytime it adds a new version or debug.
April 18, 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Burton Radons schrieb am Sun, 17 Apr 2005 17:47:45 -0700:
> This code succeeds compilation:
>
>     version (b) illegal declaration;
>     version (a) version = b;
>     version = a;
>
> However, it should fail because version "a" should be defined, then version "b", then expanding the illegal declaration.  This correctly fails:
>
>     version (b) illegal declaration;
>     version = a;
>     version (a) version = b;
>
> The compiler is only doing one pass through the declarations to find versions to assign; instead it should restart the loop anytime it adds a new version or debug.

Added to DStress as
http://dstress.kuehne.cn/run/debug_08.d
http://dstress.kuehne.cn/run/debug_09.d
http://dstress.kuehne.cn/run/debug_10.d
http://dstress.kuehne.cn/run/version_33.d
http://dstress.kuehne.cn/run/version_34.d
http://dstress.kuehne.cn/run/version_35.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFCY1e13w+/yD4P9tIRAjOpAJ90EP64D2Z002Ny6mrUOaEx+JPAzwCdFOMN
gkvkE4pXDDGhV7xvhhAegWI=
=ppeG
-----END PGP SIGNATURE-----
April 19, 2005
"Burton Radons" <burton-radons@smocky.com> wrote in message news:d3v03l$2oag$1@digitaldaemon.com...
> This code succeeds compilation:
>
>     version (b) illegal declaration;
>     version (a) version = b;
>     version = a;
>
> However, it should fail because version "a" should be defined, then version "b", then expanding the illegal declaration.  This correctly
fails:
>
>     version (b) illegal declaration;
>     version = a;
>     version (a) version = b;
>
> The compiler is only doing one pass through the declarations to find versions to assign; instead it should restart the loop anytime it adds a new version or debug.

I don't agree. Since version assignments are only local to a module, there's
no need to support forward references of versioning, and in fact, one could
get into trouble with things like:
    version (a)
        version = b;
    version (b)
        version = a;
There just seems no point to supporting forward referencing of versions.


April 19, 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Walter schrieb am Mon, 18 Apr 2005 22:46:26 -0700:
>
> "Burton Radons" <burton-radons@smocky.com> wrote in message news:d3v03l$2oag$1@digitaldaemon.com...
>> This code succeeds compilation:
>>
>>     version (b) illegal declaration;
>>     version (a) version = b;
>>     version = a;
>>
>> However, it should fail because version "a" should be defined, then version "b", then expanding the illegal declaration.  This correctly
> fails:
>>
>>     version (b) illegal declaration;
>>     version = a;
>>     version (a) version = b;
>>
>> The compiler is only doing one pass through the declarations to find versions to assign; instead it should restart the loop anytime it adds a new version or debug.
>
> I don't agree. Since version assignments are only local to a module, there's
> no need to support forward references of versioning, and in fact, one could
> get into trouble with things like:
>     version (a)
>         version = b;
>     version (b)
>         version = a;
> There just seems no point to supporting forward referencing of versions.

Having complex feature<->debug dependencies within a module can require forward referencing.

There is no risk of infinit loops since version/debug can only be set. Setting a version/debug if it is allready set shouldn't trigger a restart of the loop.

Thomas


-----BEGIN PGP SIGNATURE-----

iD4DBQFCZPbL3w+/yD4P9tIRAkscAJiPb+rX+/DG8hiFVq9w/oRqYt4HAJ4mN2mW
ZXtw0yKAcvHsjcaVnFfOrw==
=FCzQ
-----END PGP SIGNATURE-----
April 19, 2005
Walter wrote:

> "Burton Radons" <burton-radons@smocky.com> wrote in message
> news:d3v03l$2oag$1@digitaldaemon.com...
> 
>>This code succeeds compilation:
>>
>>    version (b) illegal declaration;
>>    version (a) version = b;
>>    version = a;
>>
>>However, it should fail because version "a" should be defined, then
>>version "b", then expanding the illegal declaration.  This correctly
> 
> fails:
> 
>>    version (b) illegal declaration;
>>    version = a;
>>    version (a) version = b;
>>
>>The compiler is only doing one pass through the declarations to find
>>versions to assign; instead it should restart the loop anytime it adds a
>>new version or debug.
> 
> 
> I don't agree. Since version assignments are only local to a module, there's
> no need to support forward references of versioning, and in fact, one could
> get into trouble with things like:
>     version (a)
>         version = b;
>     version (b)
>         version = a;
> There just seems no point to supporting forward referencing of versions.

Err, so why did you support them then?  :)

   version (a) illegal declaration;
   version = a;

This works, as in not works.  I'm just asking that the compiler behave consistently.  If forward version referencing weren't allowed altogether, I'd be fine with that.

Your example wouldn't do anything.  If either version a or b were enabled, then it would enable the other, opening the other statement, then do nothing because the original is already enabled.

We can't get into loops with version identifiers because we can't disable them, but with version numbers there's a potential (start with version = 1):

   version (1)
       version = 0;
   else
       version = 1;

More than one version number in a module is impossible to evaluate without taking some order dependency so could safely be considered illegal.  In fact, if forward version referencing is allowed it might be best to make them allowed but they must always increase the version.