On Sunday, 21 February 2021 at 21:03:27 UTC, Jack wrote:
Why doesn't this compiles?
class Baa
{
Foo Foo = new Foo();
}
Local variables inside functions are a little bit special because
everything happens in sequence. This is a declaration, where
there is a new namespace, but
Why doesn't this compiles?
class Baa
{
Foo Foo = new Foo();
}
On Sunday, 21 February 2021 at 18:15:22 UTC, JN wrote:
I guess D is smart enough to figure out which is a type and
which is a variable. C++ gets confused in similar situation.
Well it isn't about type vs variable (except for in this exact
declaration), it is just one is defined at top level an
On Sunday, 21 February 2021 at 18:09:29 UTC, FeepingCreature
wrote:
On Sunday, 21 February 2021 at 18:07:49 UTC, JN wrote:
class Foo
{
}
void main()
{
Foo Foo = new Foo();
}
this kind of code compiles. Is this expected to compile?
Yes, why wouldn't it? main is a different scope
On Sunday, 21 February 2021 at 18:07:49 UTC, JN wrote:
class Foo
{
}
void main()
{
Foo Foo = new Foo();
}
this kind of code compiles. Is this expected to compile?
Yes, why wouldn't it? main is a different scope than global; you
can override identifiers from global in main. And
class Foo
{
}
void main()
{
Foo Foo = new Foo();
}
this kind of code compiles. Is this expected to compile?