Re: Am I doing it wrong?

2010-10-04 Thread Jérôme M. Berger
Simen kjaeraas wrote: > Jérôme M. Berger wrote: > >> Emil Madsen wrote: >>> can the enum be a float? if calcprimes returned a float? - and if so, >>> will >>> the enum be a float or an int? (will it be casted, or will it work as an >>> auto type?) >>> >> Yes, basically "enum" is a synonym for

Re: Am I doing it wrong?

2010-10-03 Thread Simen kjaeraas
Jérôme M. Berger wrote: Emil Madsen wrote: can the enum be a float? if calcprimes returned a float? - and if so, will the enum be a float or an int? (will it be casted, or will it work as an auto type?) Yes, basically "enum" is a synonym for "compile-time const auto" (although the

Re: Am I doing it wrong?

2010-10-03 Thread Emil Madsen
So I've been told, but havn't been able to find it, so I rechecked, and there it was, apperently I'm getting blind >.< I'll make sure not to pollute this mailing list with these questions again then :) - Thanks once again On 3 October 2010 23:28, Ali Çehreli wrote: > Emil Madsen wrote: > >> ah o

Re: Am I doing it wrong?

2010-10-03 Thread Ali Çehreli
Emil Madsen wrote: ah ofc! I shoulda know :) - So I were doing it wrong :) Thanks for the question; I learned something too. :) But in case you don't already know, there is also the D.learn newsgroup. This question might be more useful there. Ali Say I'm doing that enum a = calcPrimes();

Re: Am I doing it wrong?

2010-10-03 Thread Jérôme M. Berger
Emil Madsen wrote: > can the enum be a float? if calcprimes returned a float? - and if so, will > the enum be a float or an int? (will it be casted, or will it work as an > auto type?) > Yes, basically "enum" is a synonym for "compile-time const auto" (although the "auto" part can be repl

Re: Am I doing it wrong?

2010-10-03 Thread Emil Madsen
perfect :), thanks :) On 3 October 2010 13:39, Jonathan M Davis wrote: > On Sunday 03 October 2010 04:34:31 Emil Madsen wrote: > > can the enum be a float? if calcprimes returned a float? - and if so, > will > > the enum be a float or an int? (will it be casted, or will it work as an > > auto ty

Re: Am I doing it wrong?

2010-10-03 Thread Emil Madsen
n't the compiler insure that it was evaluated at > > compiletime? - or am I doing it wrong? > > pure != CTFE > > If a function is pure, then it's result can be cached if it's called again > with > the same arguments. So, if you hade a pure sqrt() in an expression like so >

Re: Am I doing it wrong?

2010-10-03 Thread Jonathan M Davis
On Sunday 03 October 2010 04:34:31 Emil Madsen wrote: > can the enum be a float? if calcprimes returned a float? - and if so, will > the enum be a float or an int? (will it be casted, or will it work as an > auto type?) auto, enum, immutable, and const all use type inference. So, you can declare

Re: Am I doing it wrong?

2010-10-03 Thread Jonathan M Davis
houldn't the compiler insure that it was evaluated at > compiletime? - or am I doing it wrong? pure != CTFE If a function is pure, then it's result can be cached if it's called again with the same arguments. So, if you hade a pure sqrt() in an expression like so auto x = sqrt(2)

Re: Am I doing it wrong?

2010-10-03 Thread Emil Madsen
can the enum be a float? if calcprimes returned a float? - and if so, will the enum be a float or an int? (will it be casted, or will it work as an auto type?) thanks btw :) On 3 October 2010 13:28, Torarin wrote: > 2010/10/3 Emil Madsen : > > ah ofc! I shoulda know :) - So I were doing it wron

Re: Am I doing it wrong?

2010-10-03 Thread Torarin
2010/10/3 Emil Madsen : > ah ofc! I shoulda know :) - So I were doing it wrong :) > Say I'm doing that enum a = calcPrimes(); > then a will be an enum with 1 element, that I can use as an int right? Yes, effectively you are declaring an anonymous enum with one element. By default an int.

Re: Am I doing it wrong?

2010-10-03 Thread Emil Madsen
ah ofc! I shoulda know :) - So I were doing it wrong :) Say I'm doing that enum a = calcPrimes(); then a will be an enum with 1 element, that I can use as an int right? - or is there something special to be aware of? On 3 October 2010 13:20, Torarin wrote: > 2010/10/3 Emil Madsen : > > Well the

Re: Am I doing it wrong?

2010-10-03 Thread Torarin
2010/10/3 Emil Madsen : > Well the result is assigned to an immutable int, shouldn't that be a compile > const too? Immutable means that the variable, or the memory it points to, will not change. You can still assign run-time values to it: void main(string[] args) { immutable string a = args[0];

Re: Am I doing it wrong?

2010-10-03 Thread Denis Koroskin
On Sun, 03 Oct 2010 15:08:33 +0400, Emil Madsen wrote: Well the result is assigned to an immutable int, shouldn't that be a compile const too? No

Re: Am I doing it wrong?

2010-10-03 Thread Emil Madsen
>> thing; >> >> http://gist.github.com/608493 >> >> However, the program has a runtime of about 5 seconds? - in my mind, if >> the >> function is pure, shouldn't the compiler insure that it was evaluated at >> compiletime? - or am I doing it wrong? >

Re: Am I doing it wrong?

2010-10-03 Thread Denis Koroskin
nsure that it was evaluated at compiletime? - or am I doing it wrong? Make your result an "enum" (i.e. compile-time constant) if you really want to calculate it in compile-time: enum primes = calcPrimes();

Am I doing it wrong?

2010-10-03 Thread Emil Madsen
So I wrote a program, to find prime numbers, just to check out this pure thing; http://gist.github.com/608493 However, the program has a runtime of about 5 seconds? - in my mind, if the function is pure, shouldn't the compiler insure that it was evaluated at compiletime? - or am I doing it

Re: Am I doing it wrong or is this a bug ?

2010-08-12 Thread Ezneh
Mafi Wrote: > Hi, > returning an int works because D's int and most other language's (eg > C's) int are identical. D's string is an alias for 'immutable(char)[]'. > The brackets [] idicate an D array. D arrays are not the same as C > arrays. In C strings are char* pointing to a null terminated

Re: Am I doing it wrong or is this a bug ?

2010-08-12 Thread Ezneh
Ezneh Wrote: > Richard Webb Wrote: > > > Is returning a D string to a non-D language going to cause problems? > > Hmm it seems that returning an int works but returning string / char types > doesn't work ... > > > Anyone knows why ? PS : "works" is kinda like "doesn't return an exception" b

Re: Am I doing it wrong or is this a bug ?

2010-08-12 Thread Mafi
Am 12.08.2010 15:59, schrieb Ezneh: Richard Webb Wrote: Is returning a D string to a non-D language going to cause problems? Hmm it seems that returning an int works but returning string / char types doesn't work ... Anyone knows why ? Hi, returning an int works because D's int and most o

Re: Am I doing it wrong or is this a bug ?

2010-08-12 Thread Ezneh
Richard Webb Wrote: > Is returning a D string to a non-D language going to cause problems? Hmm it seems that returning an int works but returning string / char types doesn't work ... Anyone knows why ?

Re: Am I doing it wrong or is this a bug ?

2010-08-12 Thread Richard Webb
Is returning a D string to a non-D language going to cause problems?

Re: Am I doing it wrong or is this a bug ?

2010-08-12 Thread Ezneh
Don Wrote: > You need to make dllprint an extern(C) function. If you just mark it as > 'extern', it uses D name mangling, which the other language won't > understand. Seems to work with test.d but I got something like "AccessViolationException - Trying to access to a protected memory (read/wr

Re: Am I doing it wrong or is this a bug ?

2010-08-12 Thread Don
Ezneh wrote: Hello ! I'm doing some tests with the DLL example which is in the samples directory but I have some problem with it. Well, when I'm compiling the DLL with that files, I got no error and it works in the test.d sample but doesn't work in another project (in another language) : //

Am I doing it wrong or is this a bug ?

2010-08-12 Thread Ezneh
Hello ! I'm doing some tests with the DLL example which is in the samples directory but I have some problem with it. Well, when I'm compiling the DLL with that files, I got no error and it works in the test.d sample but doesn't work in another project (in another language) : //mydll.d module