1. 7
  1.  

  2. 5

    As someone who feels pretty comfortable with pointers, I found this article to be:

    1. longer than 5 minutes to go through,
    2. fairly confusing and unfocused, and
    3. provides background info at too varied of abstraction levels. There’s assembly, calling conventions, syntax, and types.

    I may be biased as I’m in the middle of instructing a beginner C course right now, and this would definitely go over the students’ heads. I find its much more helpful to offer different mental models and visualizations of the underlying abstract machine. One explanation will not satisfy and click with everybody.

    I do like beginning with something seemingly simple. “What is a variable?” is a great question to start peeling back the layers in C. Especially defining a pointer as a variable! A common misconception I see is conflating pointers and objects on the heap. A variable is an object on the stack. A variable has a name so you can use it. Some objects don’t have a name so they’re a little harder to use. A pointer can be variable. A pointer can point to anywhere, so they could help you use that object without a name! (or any other object). Alas, as I mentioned earlier, this would also whoosh over some heads.

    1. 3

      But not all variables live on the stack—global and static variables (even those defined in functions) live in the data segment [1]. Probably a better high level definition—a variable is a named location to store data, but said location can be ephemeral (in the case of non-static variables defined in a function).

      [1] Or bss segment.

      1. 1

        That is indeed a better definition! I try to avoid the topic of global variables with beginners to avoid nasty practices, but they should not get a faulty definition.

        1. 1

          And note that some variables may only ever exist in registers.