Compile-Time Functions - Allocating Memory?
Jarrett Billingsley
kb3ctd2 at yahoo.com
Tue Jul 22 20:59:37 PDT 2008
"Era Scarecrow" <rtcvb32 at yahoo.com> wrote in message
news:g664l0$2bia$1 at digitalmars.com...
>
> I'm trying to compose as a test, where i fill a precompiled list of
> numbers in an array. What step am i missing to make this part work? (I i'm
> using gdc). it keeps complaining of a non-constant expression. Is there
> any way to make this work?
>
> bool []primes = tp(1000);
Completely off-topic, but a stylistic point. Putting the brackets next to
the name is a bit misleading in D, since unlike in C, type decorators do not
attach to the variables but instead to the base type. That is,
char * x, y;
in C means that x is a pointer to a char, while y is a char; but in D,
they're both char*. For that reason it's recommended that the
brackets/asterisks attach to the type.
(I still can't quite figure out why you also use "bool [] tp" and "bool[]
tmp". Usually people are consistent about these things ;) )
More information about the Digitalmars-d-learn
mailing list