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
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
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
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();
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
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
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
>
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
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)
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
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.
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
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];
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
>> 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?
>
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();
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
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
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
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
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 ?
Is returning a D string to a non-D language going to cause problems?
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
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) :
//
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
25 matches
Mail list logo