version and extern problems

BCS ao at pathlink.com
Tue Jul 10 19:08:10 PDT 2007


Reply to Walter,

> BCS wrote:
> 
>> That is one thing I have never understood: why does lexical order
>> ever (outside of statement lists e.i. function) ever cause an issue?
>> 
> const string x = "abc" ~ foo;
> const string foo = x[1..4];

That has little or nothing to do with lexical order. Baring retro-order dependencies 
does remove this type of error, but it also bars otherwise valid code.

I would propose that the evaluation could run like this:

use rand() to pick something to start with (not needed but it would work 
anyway)
attempt to evaluate value of foo
foo requires x
attempt to evaluate value of x
x requires foo
we have started but not finished evaluating x therefor "Error: cyclical dependency 
for foo"


The same model could be used for auto typing, template evaluation or whatever. 
As long as you never have to evaluate something as part of evaluating itself, 
order can be ignored.





More information about the Digitalmars-d mailing list