4 ms·
> It would be in a register. Of course. Or it would be eliminated by a compiler optimization. Of course. Since you mention relevance for beginners later on in
by fps_doug 5y ago
> It would be in a register. Of course. Or it would be eliminated by a compiler optimization. Of course.
Since you mention relevance for beginners later on in your post I'd argue this isn't relevant either. This concept holds true for simple code that doesn't do advanced stuff like working with hardware. As soon as you do &variable, you get an address and can work with it. If the compiler optimized something away you never use you might as well just pretend it's in memory somewhere for the sake of a mental model that's easy to grasp. Same with passing variables via stack. A simple compiler could do it just like that.
That isn't to say the tutorial is good/not good, but these points in particular seem rather sane to me. Far from "Mastering C Pointers" at least :)
- tom_mellior 5y ago> Since you mention relevance for beginners later on in your post I'd argue this isn't relevant either. Agreed. At the time that variables are introduced, it should just say "a variable is a name for a location where a value is stored". I didn't mean to suggest that the tutorial should go into needless detail at that point. Just that the needless detail that it currently goes into is wrong. > Same with passing variables via stack. Again, my problem is just with the needless detail. When you pass a value it is copied (that is the relevant part) somewhere where the callee can find it (that somewhere is the irrelevant part).