June 02, 2005 Foreward Refrencing | ||||
---|---|---|---|---|
| ||||
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
|
June 02, 2005 Re: Foreward Refrencing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trevor Parscal | 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?
>
|
Copyright © 1999-2021 by the D Language Foundation