www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Getting whether it's Tango or Phobos

reply Robert Fraser <fraserofthenight gmail.com> writes:
Is there a reliable way to deduce whether the user is using Tango or 
Phobos? I used to use:

static if(is(typeof(object.toUtf8)))

But since that got changed to toString that doesn't work right now. For 
the time being, I can verify it's D1 and then use (with Tango 0.99.6)

static if(!is(typeof(string)))

But I'm guessing Tango may be given a string type soon...?
May 19 2008
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Robert Fraser wrote:
 Is there a reliable way to deduce whether the user is using Tango or 
 Phobos? I used to use:
 
 static if(is(typeof(object.toUtf8)))
 
 But since that got changed to toString that doesn't work right now. For 
 the time being, I can verify it's D1 and then use (with Tango 0.99.6)
 
 static if(!is(typeof(string)))
 
 But I'm guessing Tango may be given a string type soon...?

version(Tango) { ... } else { ... } ? --bb
May 19 2008
parent reply Robert Fraser <fraserofthenight gmail.com> writes:
Bill Baxter wrote:
 Robert Fraser wrote:
 Is there a reliable way to deduce whether the user is using Tango or 
 Phobos? I used to use:

 static if(is(typeof(object.toUtf8)))

 But since that got changed to toString that doesn't work right now. 
 For the time being, I can verify it's D1 and then use (with Tango 0.99.6)

 static if(!is(typeof(string)))

 But I'm guessing Tango may be given a string type soon...?

version(Tango) { ... } else { ... } ? --bb

That requires the user to specify -version=Tango . I'm looking for something that can be compiled with either Tango or Phobos without asking anything of the user.
May 19 2008
next sibling parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Robert Fraser wrote:
 Bill Baxter wrote:
 Robert Fraser wrote:
 Is there a reliable way to deduce whether the user is using Tango or 
 Phobos? I used to use:

 static if(is(typeof(object.toUtf8)))

 But since that got changed to toString that doesn't work right now. 
 For the time being, I can verify it's D1 and then use (with Tango 
 0.99.6)

 static if(!is(typeof(string)))

 But I'm guessing Tango may be given a string type soon...?

version(Tango) { ... } else { ... } ? --bb

That requires the user to specify -version=Tango . I'm looking for something that can be compiled with either Tango or Phobos without asking anything of the user.

But it's part of the standard Tango install/setup procedure. If you follow the instructions for how to install Tango, then you will always have -version=Tango set when using Tango. Are you worried about the case where someone has not followed Tango's install procedures properly? --bb
May 19 2008
prev sibling next sibling parent reply Sean Kelly <sean invisibleduck.org> writes:
Robert Fraser wrote:
 Bill Baxter wrote:
 Robert Fraser wrote:
 Is there a reliable way to deduce whether the user is using Tango or 
 Phobos? I used to use:

 static if(is(typeof(object.toUtf8)))

 But since that got changed to toString that doesn't work right now. 
 For the time being, I can verify it's D1 and then use (with Tango 
 0.99.6)

 static if(!is(typeof(string)))

 But I'm guessing Tango may be given a string type soon...?

version(Tango) { ... } else { ... } ? --bb

That requires the user to specify -version=Tango . I'm looking for something that can be compiled with either Tango or Phobos without asking anything of the user.

Tango actually requires that version=Tango be set for the installation to be considered complete. I suppose we could enforce this by adding a static failure condition to Tango's object.d file, but I'd like to think that making it a default part of the bundled Tango installs and documenting the requirement in our manual install docs would be sufficient. Sean
May 19 2008
parent reply "Chris R. Miller" <lordSaurontheGreat gmail.com> writes:
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Sean Kelly wrote:
 Robert Fraser wrote:
 That requires the user to specify -version=3DTango . I'm looking for=20
 something that can be compiled with either Tango or Phobos without=20
 asking anything of the user.

Tango actually requires that version=3DTango be set for the installatio=

 to be considered complete.  I suppose we could enforce this by adding a=

 static failure condition to Tango's object.d file, but I'd like to thin=

 that making it a default part of the bundled Tango installs and=20
 documenting the requirement in our manual install docs would be suffici=

I also wonder how that would behave with Tangobos, which could cause=20 issues with Phobos code expecting a version=3DPhobos, which would conflic= t=20 with version=3DTango. Perhaps I'm wrong, but that could present a proble= m.
May 19 2008
parent Sean Kelly <sean invisibleduck.org> writes:
Chris R. Miller wrote:
 Sean Kelly wrote:
 Robert Fraser wrote:
 That requires the user to specify -version=Tango . I'm looking for 
 something that can be compiled with either Tango or Phobos without 
 asking anything of the user.

Tango actually requires that version=Tango be set for the installation to be considered complete. I suppose we could enforce this by adding a static failure condition to Tango's object.d file, but I'd like to think that making it a default part of the bundled Tango installs and documenting the requirement in our manual install docs would be sufficient.

I also wonder how that would behave with Tangobos, which could cause issues with Phobos code expecting a version=Phobos, which would conflict with version=Tango. Perhaps I'm wrong, but that could present a problem.

I'd probably still set version=Tango in that instance, but the user could probably set either or both safely, depending on how third party libraries are implemented. Sean
May 19 2008
prev sibling parent Mike Parker <aldacron gmail.com> writes:
Robert Fraser wrote:
 Bill Baxter wrote:
 Robert Fraser wrote:
 Is there a reliable way to deduce whether the user is using Tango or 
 Phobos? I used to use:

 static if(is(typeof(object.toUtf8)))

 But since that got changed to toString that doesn't work right now. 
 For the time being, I can verify it's D1 and then use (with Tango 
 0.99.6)

 static if(!is(typeof(string)))

 But I'm guessing Tango may be given a string type soon...?

version(Tango) { ... } else { ... } ? --bb

That requires the user to specify -version=Tango . I'm looking for something that can be compiled with either Tango or Phobos without asking anything of the user.

I've been using this in Derelict for a long while now with no complaints and I know it's used in other libraries. Any one who doesn't have version=Tango defined when using Tango will find himself with a broken installation.
May 19 2008