reusing private variables

Hi,
I have some general question about reusing a variable-name. I have some variables which reappear in some functions. Should I give them unique names or is there no problem, even if the functions could be active at the same time:

int funct(int name) {
  return 10;
}
int function(int name) {
  return funct(name);
}
void loop {
a = function(name);
}

thanks

Useful starter reading

void loop {
a = function(name);  //there is nothing in scope here called "name"
}

even if the functions could be active at the same time:

There is only one processor and only one thread so the functions can't be active at the same time.

He may be meaning a function being called by another...

He may be meaning a function being called by another

That would be nesting.

Yes it would. I'm just trying to be generous in understanding someone who's clearly new to this.

generous

{ checks dictionary } Ah! OK, yes.

Useful starter reading
scope - Arduino Reference

This is were my question is aiming at.

There is only one processor and only one thread so the functions can't be active at the same time.

as a "active" function I meant a "not yet ended" function. This does not have to mean, that they are processed simultanously.

He may be meaning a function being called by another...

right. that is what I mean.

That would be nesting.

okay. I try to ask my question using the correct terms:

Is it completely unproblematic to call a function with a parameter "name" if the function I am calling from has a parameter "name", too? Or might this (in any case) cause some problems)?

There should be no problems.

KevinT:
Is it completely unproblematic to call a function with a parameter "name" if the function I am calling from has a parameter "name", too? Or might this (in any case) cause some problems)?

There's a couple cases of what you're asking here:

this

void foo(int a) { bar(a); }
void bar(int a) { Serial.print(a); }

foo(1);

and this

void foo(int a) { bar(a); }
void bar(int b) { Serial.print(b); }

foo(1);

will both output this

1

but if you do something like this:

void foo(int a) { int a = 2; bar(a); }
void bar(int b) { Serial.print(b); }

foo(1);

the output will be

2

@AWOL: thanks. That was the answer I was lurking for :slight_smile:

@Aeturnalus: sure. with "problems" I meant some internal problems, not me mixing up variables :slight_smile: