Why doesn't this have a length?

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Mar 12 11:20:07 PDT 2012


On 3/12/12, Ali Çehreli <acehreli at yahoo.com> wrote:
> Let's please also see the exact error message. "an error message that
> seems to indicate that DMD is looking for a global identifier" is not
> clear to mortals like myself. :)

He probably means something like this:

struct State { }
struct Input { }
State[][Tuple!(const(State), const(Input))] transitions;

void main() {
    writeln(transitions.length);
}

test.d(20): Error: undefined identifier module test.length

Note that typeid doesn't work either:
writeln(typeid(transitions));
D:\DMD\dmd2\windows\bin\..\..\src\druntime\import\object.di(507):
Error: can only initialize const member key inside constructor

This seems to be an issue related with const. Without const both calls work.


More information about the Digitalmars-d-learn mailing list