On Friday, January 19, 2018 10:11:36 H. S. Teoh via Digitalmars-d-learn
wrote:
> Fortunately this is not the case. However, the static variable case is
> annoying, and it's actually one case of a larger problem:
>
> void main() {
> foreach (i; 0 .. 10) {
> struct S {
>
On 1/19/18 1:11 PM, H. S. Teoh wrote:
Fortunately this is not the case. However, the static variable case is
annoying, and it's actually one case of a larger problem:
void main() {
foreach (i; 0 .. 10) {
struct S {
On Fri, Jan 19, 2018 at 02:16:24PM +, tipdbmp via Digitalmars-d-learn wrote:
> > Mostly, it's just a bad idea - it's very easy for a person reading
> > the code after you've written it to get the two x's mixed up.
>
> // example from: 19.17.1.3
> void main()
> {
> { static int x; }
> {
Mostly, it's just a bad idea - it's very easy for a person
reading the code after you've written it to get the two x's
mixed up.
// example from: 19.17.1.3
void main()
{
{ static int x; }
{ static int x; } // error
{ int i; }
{ int i; } // ok
}
I don't really see how the 'stati
On Friday, 19 January 2018 at 11:02:01 UTC, tipdbmp wrote:
The following seems to work in C++, but errors in D, why is
that?
int foo(int* num) {
{
static int x = 10;
x += 1;
*num += x;
}
{
static int x = 20; // error: foo.x is already defined
in ano
The following seems to work in C++, but errors in D, why is that?
int foo(int* num) {
{
static int x = 10;
x += 1;
*num += x;
}
{
static int x = 20; // error: foo.x is already defined in
another scope in foo
x += 2;
*num += x;
}