www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Phobos Help Request: Aliases and CTFE

This is a help request for a pull I am working on:
https://github.com/D-Programming-Language/phobos/pull/727

It is just a basic templated struct.

The issue I'm having comes from this line (1069), where I am 
trying to define a compile-time string:
----
enum string seedExceptionText = text("LaggedFibonacciEngine.seed: 
Input range didn't provide"
" enough elements: Need ", longLag, " elements.");
----
Note: longLag is a template parameter of type size_t.

This line, in and out of itself, works. The problem is that once 
I declare my "generators with well-chosen parameters" aliases, 
all hell breaks loose:
----
alias LaggedFibonacciEngine!(double, 48,   607,   273)   
LaggedFibonacci607;
alias LaggedFibonacciEngine!(double, 48,  1279,   418)  
LaggedFibonacci1279;
[...]
alias LaggedFibonacci607 LaggedFibonacci;
----

Here is the diff where I *removed* these aliases:
https://github.com/monarchdodra/phobos/commit/4f333a22a5bcae50357f305fd0611a31255de101#std/random.d

After removing them, these compilation errors seized to exist 
(different messages on different machines):
http://d.puremagic.com/test-results/pull.ghtml?runid=276052
http://d.puremagic.com/test-results/pull.ghtml?runid=276053
http://d.puremagic.com/test-results/pull.ghtml?runid=276054
The error message, in a word, is:
std/conv.d(3040): Error: template std.conv.text(T...) forward 
reference to template text(T...)
Which originate from the alias declarations.

What does "forward reference" even mean in this context?

The (very?) strange parts here I am having trouble wrapping my 
head around is that std.random compiles and unittests fine. It is 
actually std.algorithm that is having trouble importing 
std.random, when trying to instantiate(?) the aliases...

I really could use a bit of enlightenment here...
Sep 05 2012