another idea for compile time functions

janderson askme at me.com
Thu Feb 8 23:57:19 PST 2007


Kevin Bealer wrote:
> Let's say I have these two functions:
> 
> char[] foo(char[] a, char[] b) metaok;
> char[] bar(char[] a, char[] b, char[] c) metaok;
> 
> The metaok keyword means "this can be run at compile time."
> 
> Suppose further that bar(a,b,c) calls foo(a,b) as a base case, and that 
> both are generated via the "meta" mechanism.  No mutual recursion or 
> anything though.
> 
> What order do you compile them in?  Obviously, foo then bar -- bar needs 
> foo to be runable at compile time.
> 

> Kevin

I think that is a good case for labeling which functions are 
compile-time safe, although I think it solveable.

Here's another case for problems:

void

mixin
{
"char [] foo1" ~ foo3 ~ "{...}"
};

void

mixin
{
"foo2" ~ foo1()  ~ "{...}"
};


How is the compiler going to figure that one out.  Parhaps there should 
be some more rules to help with these cases?  Maybe its possible to 
compile it?  Maybe something to do with namespacing?  I'm not sure.  I 
think would be possible.

I think you shouldn't be able to access functions a compile time defined 
in a mixin.  But I'm sure there are many other cases like this to figure 
out.

-Joel



More information about the Digitalmars-d mailing list