Just out of curiosity, do you know any other programming languages? Especially C/C++. The understanding you seek is about the true nature of variables and memory addresses in the RAM. “a’s argument” is 12 characters long. Let’s say that we are using ASCII encoding, so each character requires 1 byte of memory. A 12-char string requires 12 bytes of memory. Each variable, regardless of name, that can store that string needs the CPU to reserve a 12-byte block of memory in the RAM. The RAM is like a giant piece of tape, and let’s say the first
str variable (Let’s call it
a.str), starts at byte 0, and goes through byte 11, and probably needs one more byte to represent the length of the string (but let’s ignore that for now). Since most computers now address memory with 32-bits (4 bytes) at a minimum, that means that, realistically, the characters take bytes 0-11 of the RAM and one more for the length, but
a.str “points” to the beginning of the first 128-bit (16 byte) block of memory. Since the function call to
b(), the next memory that needs to be allocated is for
b.str. Like before, the minimum amount of memory that is addressable is 4 bytes at a time. So, we have to reserve 16 bytes. So,
b.str gets bytes 16-31 of the RAM, but only occupies 12 of those bytes.
Now, here’s where the real answer to your question lies. The CPU doesn’t care what your variable name was. It knows that a.str is “bytes 0-11 of RAM” and that b.str is “bytes 16-27 of RAM”. Now, at first, you may think, “Well, then by naming the variables the same in subordinate functions, I’m only confusing myself.” BUT: If you can visualize what’s going on in the RAM, you can understand variable scope MUCH better, and then a.str and b.str are GOOD names, because they let you and other programmers know that you are passing in copies of the same value into the two areas of RAM, but they are the SAME VALUE that is being passed in, and the meaning of the operation you are programming is much easier to follow.
BTW, in C/C++, this whole discussion is the basis of understanding pointers. So, if you understood what I wrote, pat yourself on the back. Pictures will make it much easier if you wanted to google more.