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
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.
Thank you both for the reply.Sorry for the lack of the signature of 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.
Aug 03 2010
parent reply "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.
Thank you both for the reply.Sorry for the lack of the signature of 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
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 reply "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
next sibling parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
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
Aug 04 2010
parent reply "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
parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
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(...))?
But char[1 + ...] is already a type, no? I thought typeof() was to extract type from an expression?
Aug 04 2010
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(...))?
But char[1 + ...] is already a type, no? I thought typeof() was to extract type from an expression?
Yes, you are right, I'll just shut up now :) -Steve
Aug 04 2010
prev sibling 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