www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - cannot evalute mixin(uuid("bla")) at compile time

reply Sam Hu <samhu.samhuat gmail.com> writes:
Base on D1:
interface IADsPropertyEntry : IDispatch {   
  mixin(uuid("05792c8e-941f-11d0-8529-00c04fd8d503"));   
  ...  
Error when compile:
argument to mixin must be a string,not
mixin(uuid("05792c8e-941f-11d0-8529-00c04fd8d503"))   
cannot evaluate uuid("05792c8e-941f-11d0-8529-00c04fd8d503") at compile time  

What's the problem and how to solve it?Thanks for your help in advance.

Regards,
Sam
Aug 03 2010
parent reply Gareth Charnock <gareth oerc.ox.ac.uk> writes:
On 03/08/10 15:19, Sam Hu wrote:
 Base on D1:
 interface IADsPropertyEntry : IDispatch {
    mixin(uuid("05792c8e-941f-11d0-8529-00c04fd8d503"));
    ...
 Error when compile:
 argument to mixin must be a string,not
mixin(uuid("05792c8e-941f-11d0-8529-00c04fd8d503"))
 cannot evaluate uuid("05792c8e-941f-11d0-8529-00c04fd8d503") at compile time

 What's the problem and how to solve it?Thanks for your help in advance.

 Regards,
 Sam

I'm not to sure what uuid(string) does but check that: 1) It can be evaluated at compile time and 2) It returns a string. Perhaps post the source of uuid (or at least the signature) so we can work out why it can't be evaluated at compile time?
Aug 03 2010
next sibling parent reply Richard Webb <webby beardmouse.org.uk> writes:
The Juno library has a 'uuid' that works like that, and the posted example seems
to build ok here using DMD 1.062.

Theres also a Tango version of the same code in the dwin library, but i haven't
tried that for ages.
Aug 03 2010
parent reply Sam Hu <samhudotsamhu gmail.com> writes:
Richard Webb Wrote:

 The Juno library has a 'uuid' that works like that, and the posted example
seems
 to build ok here using DMD 1.062.
 
 Theres also a Tango version of the same code in the dwin library, but i haven't
 tried that for ages.

char[] uuid(char[] g) { ... } char[] uuid(char[] type, char[] g) { ... } Richard:Yes,you is right.This is from dwin on which I tried to work out for the latest tango.Btw,have you got a workable version of juno for current D2?I tried several times but finally gave up.
Aug 03 2010
parent reply Richard Webb <webby beardmouse.org.uk> writes:
Dwin uses Tango and so only works in D1 anyway, so i don't know if thats the
problem (Juno uses string already, and i've used that ok in D1 and D2).

I've managed to get Juno working with a recent D2 before, but with the latest
SVN
version i get:

///////////////////////////////////////////////
phobos\std\range.d(645): Error: cannot evaluate
empty((const(immutable(char)[])))
at compile time

phobos\std\range.d(645): Error: Integer constant expression expected instead of
cast(uint)(1 + cast(int)empty((const(immutable(char)[]))))
///////////////////////////////////////////////

I haven't worked out whats causing the problem yet, though looking at the Phobos
code i'm not sure what the

       is(char[1 + Range.empty]))

is supposed to be doing.
Aug 04 2010
parent Richard Webb <webby beardmouse.org.uk> writes:
I don't have a minimal example, but i have found that the error only occurs with
the most recent version of std.algorithm -> the current SVN version of phobos
with
the previous revision of algorithm compiles ok.
Aug 04 2010
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 03 Aug 2010 21:04:26 -0400, Sam Hu <samhudotsamhu gmail.com> wrote:

 Richard Webb Wrote:

 The Juno library has a 'uuid' that works like that, and the posted  
 example seems
 to build ok here using DMD 1.062.

 Theres also a Tango version of the same code in the dwin library, but i  
 haven't
 tried that for ages.

uuid.Here they are: char[] uuid(char[] g) { ... } char[] uuid(char[] type, char[] g) { ... } Richard:Yes,you is right.This is from dwin on which I tried to work out for the latest tango.Btw,have you got a workable version of juno for current D2?I tried several times but finally gave up.

In d2, strings are represented by immutable(char)[]. Change uuid to return and accept string (and fix any resulting bugs). -Steve
Aug 04 2010
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Wed, 04 Aug 2010 08:35:18 -0400, Richard Webb <webby beardmouse.org.uk>  
wrote:

 Dwin uses Tango and so only works in D1 anyway, so i don't know if thats  
 the
 problem (Juno uses string already, and i've used that ok in D1 and D2).

All I'm saying is that is what the error message is saying "you're trying to mixin something that's not a string. It needs to be string" Other than that, I'm not sure how to make dwin or juno work with a proper string type.
 I've managed to get Juno working with a recent D2 before, but with the  
 latest SVN
 version i get:

 ///////////////////////////////////////////////
 phobos\std\range.d(645): Error: cannot evaluate  
 empty((const(immutable(char)[])))
 at compile time

 phobos\std\range.d(645): Error: Integer constant expression expected  
 instead of
 cast(uint)(1 + cast(int)empty((const(immutable(char)[]))))
 ///////////////////////////////////////////////

 I haven't worked out whats causing the problem yet, though looking at  
 the Phobos
 code i'm not sure what the

        is(char[1 + Range.empty]))

Not sure either, but empty called on a string should be evaluatable at compile time. You should file a bug with a minimal example. -STeve
Aug 04 2010
prev sibling next sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
--00032555a1169f6649048d03eea1
Content-Type: text/plain; charset=ISO-8859-1

On Wed, Aug 4, 2010 at 14:48, Steven Schveighoffer <schveiguy yahoo.com>wrote:

 On Wed, 04 Aug 2010 08:35:18 -0400, Richard Webb <webby beardmouse.org.uk>
 wrote:

     I haven't worked out whats causing the problem yet, though looking at
 the Phobos

 code i'm not sure what the

       is(char[1 + Range.empty]))

Not sure either, but empty called on a string should be evaluatable at compile time. You should file a bug with a minimal example.

Isn't that the trick used to test for infinite ranges? Infinite ranges are defined to have an 'enum bool empty = false' member. So, for an infinite range, 1+Range.empty is a compile-time expression that can be used as dimension for a static array. Else, .empty is a function and I suppose the is() returns false. Or something like that, anyway. Philippe --00032555a1169f6649048d03eea1 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Wed, Aug 4, 2010 at 14:48, Steven Schveighoff= er <span dir=3D"ltr">&lt;<a href=3D"mailto:schveiguy yahoo.com">schveiguy y= ahoo.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style= =3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> <div class=3D"im">On Wed, 04 Aug 2010 08:35:18 -0400, Richard Webb &lt;<a h= ref=3D"mailto:webby beardmouse.org.uk" target=3D"_blank">webby beardmouse.o= rg.uk</a>&gt; wrote:<br></div></blockquote><div>=A0</div><blockquote class= =3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd= ing-left:1ex;"> <div class=3D"im">=A0=A0 =A0I haven&#39;t worked out whats causing the prob= lem yet, though looking at the Phobos</div><div class=3D"im"><blockquote cl= ass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;p= adding-left:1ex"> code i&#39;m not sure what the<br> <br> =A0 =A0 =A0 is(char[1 + Range.empty]))<br> </blockquote> <br></div> Not sure either, but empty called on a string should be evaluatable at comp= ile time. =A0You should file a bug with a minimal example.<br></blockquote>= <div><br></div><div>Isn&#39;t that the trick used to test for infinite rang= es? Infinite ranges are defined to have an =A0&#39;enum bool empty =3D fals= e&#39; member. So, for an infinite range, 1+Range.empty is a compile-time e= xpression that can be used as dimension for a static array.</div> <div>Else, .empty is a function and I suppose the is() returns false.</div>= <div><br></div><div>Or something like that, anyway.</div><div><br></div><di= v><br></div><div>Philippe</div><div><br></div><div><br></div><div><br></div=

--00032555a1169f6649048d03eea1--
Aug 04 2010
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Wed, 04 Aug 2010 14:52:14 -0400, Philippe Sigaud  
<philippe.sigaud gmail.com> wrote:

 On Wed, Aug 4, 2010 at 14:48, Steven Schveighoffer  
 <schveiguy yahoo.com>wrote:

 On Wed, 04 Aug 2010 08:35:18 -0400, Richard Webb  
 <webby beardmouse.org.uk>
 wrote:

     I haven't worked out whats causing the problem yet, though looking  
 at
 the Phobos

 code i'm not sure what the

       is(char[1 + Range.empty]))

Not sure either, but empty called on a string should be evaluatable at compile time. You should file a bug with a minimal example.

Isn't that the trick used to test for infinite ranges? Infinite ranges are defined to have an 'enum bool empty = false' member. So, for an infinite range, 1+Range.empty is a compile-time expression that can be used as dimension for a static array. Else, .empty is a function and I suppose the is() returns false. Or something like that, anyway.

Hm..., then shouldn't that be is(typeof(...))? -Steve
Aug 04 2010
prev sibling next sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
--0050450243963943d2048d062801
Content-Type: text/plain; charset=ISO-8859-1

On Wed, Aug 4, 2010 at 22:00, Steven Schveighoffer <schveiguy yahoo.com>wrote:

 code i'm not sure what the

      is(char[1 + Range.empty]))

Hm..., then shouldn't that be is(typeof(...))?



type from an expression? --0050450243963943d2048d062801 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Wed, Aug 4, 2010 at 22:00, Steven Schveighoff= er <span dir=3D"ltr">&lt;<a href=3D"mailto:schveiguy yahoo.com">schveiguy y= ahoo.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style= =3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div class=3D"im"><blockquote class=3D"gmail= _quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:= 1ex"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-le= ft:1px #ccc solid;padding-left:1ex"> <br>code i&#39;m not sure what the<br> <br> =A0 =A0 =A0is(char[1 + Range.empty]))<br> <br> </blockquote> <br><br></blockquote></div></blockquote> Hm..., then shouldn&#39;t that be is(typeof(...))?<br><br></blockquote><div=
<br></div><div>But char[1 + ...] is already a type, no? I thought typeof()=

--0050450243963943d2048d062801--
Aug 04 2010
prev sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Wed, 04 Aug 2010 17:31:30 -0400, Philippe Sigaud  
<philippe.sigaud gmail.com> wrote:

 On Wed, Aug 4, 2010 at 22:00, Steven Schveighoffer  
 <schveiguy yahoo.com>wrote:

 code i'm not sure what the

      is(char[1 + Range.empty]))

Hm..., then shouldn't that be is(typeof(...))?



extract type from an expression?

Yes, you are right, I'll just shut up now :) -Steve
Aug 04 2010