www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Foreward Refrencing

reply Trevor Parscal <trevorparscal hotmail.com> writes:
OK, I figure it out, but now I have another problem.

foo.d -----------------------
module foo;
import everything;
int myfoo = mybar;

bar.d -----------------------
module bar;
import everything;
int mybar = 1;

everything.d ----------------
module everything;
public
{
     import foo;
     import bar;
}

test.d ----------------------
import everything;
import std.stdio;
import std.string;
int main(char[][] args)
{
     writefln(format(myfoo, mybar));
     return 0;
}

-----------------------------

foo.d(3): identifier 'mybar' is not defined

Now, shouldn't this work? Why is it giving me this?

And what is a package? what does the package keyword do?

-- 
Thanks,
Trevor Parscal
www.trevorparscal.com
trevorparscal hotmail.com
Jun 02 2005
parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
Module foo must import module bar.

A package is like a directory.  For example, "foo.main", "foo.data", 
"foo.everything", and "foo.blah" make one package (foo.)

-[Unknown]


 OK, I figure it out, but now I have another problem.
 
 foo.d -----------------------
 module foo;
 import everything;
 int myfoo = mybar;
 
 bar.d -----------------------
 module bar;
 import everything;
 int mybar = 1;
 
 everything.d ----------------
 module everything;
 public
 {
     import foo;
     import bar;
 }
 
 test.d ----------------------
 import everything;
 import std.stdio;
 import std.string;
 int main(char[][] args)
 {
     writefln(format(myfoo, mybar));
     return 0;
 }
 
 -----------------------------
 
 foo.d(3): identifier 'mybar' is not defined
 
 Now, shouldn't this work? Why is it giving me this?
 
 And what is a package? what does the package keyword do?
 
Jun 02 2005