On Friday, I omitted to mention one of the great gifts for which I give thanks this year: the birth (and continued thriving, despite some edgy surprises) of Cameron, Ruairi, and Sawyer. They and their parents have been through a lot with us, and we marvel again at the ways that a child can transform the lives not only of beginners, but even of grizzled veteran parents. Bless you, all!
Posted by AKMA at May 25, 2003 08:30 AM | TrackBackThank you, AKMA.
Posted by: Gary, Fiona & Cameron at May 25, 2003 12:12 PMAKMA, Margaret - thank YOU, with an extra dollop of gratitude for making Michael the grizzled one.
Posted by: tom & wendy & sawyer at May 25, 2003 12:35 PMTHANK YOU, AKMA, Margaret and your lovely family. Grace & peace to you all.
First time I've ever been awarded the soubriquet "grizzled". I'm seeing myself in an entirely new light now - battle-scarred, windswept, and much more interesting than I am in real life. Oh, and with a huge scruffy beard.
I've always quite fancied a touch of grizzling. Thanks indeed
/m
Posted by: Michael, Leona, Charlie, Lily & Ruairi at May 26, 2003 07:55 AMEarlier I mentioned that variables can live in two different places. We're going to examine these two places one at a time, and we're going to start on the more familiar ground, which is called the Stack. Understanding the stack helps us understand the way programs run, and also helps us understand scope a little better.
Posted by: Rose at January 12, 2004 06:46 PMNote the new asterisks whenever we reference favoriteNumber, except for that new line right before the return.
Posted by: Cassandra at January 12, 2004 06:46 PMThis is another function provided for dealing with the heap. After you've created some space in the Heap, it's yours until you let go of it. When your program is done using it, you have to explicitly tell the computer that you don't need it anymore or the computer will save it for your future use (or until your program quits, when it knows you won't be needing the memory anymore). The call to simply tells the computer that you had this space, but you're done and the memory can be freed for use by something else later on.
Posted by: Henry at January 12, 2004 06:46 PMBut some variables are immortal. These variables are declared outside of blocks, outside of functions. Since they don't have a block to exist in they are called global variables (as opposed to local variables), because they exist in all blocks, everywhere, and they never go out of scope. Although powerful, these kinds of variables are generally frowned upon because they encourage bad program design.
Posted by: Bertram at January 13, 2004 07:20 AMNote first that favoriteNumbers type changed. Instead of our familiar int, we're now using int*. The asterisk here is an operator, which is often called the "star operator". You will remember that we also use an asterisk as a sign for multiplication. The positioning of the asterisk changes its meaning. This operator effectively means "this is a pointer". Here it says that favoriteNumber will be not an int but a pointer to an int. And instead of simply going on to say what we're putting in that int, we have to take an extra step and create the space, which is what does. This function takes an argument that specifies how much space you need and then returns a pointer to that space. We've passed it the result of another function, , which we pass int, a type. In reality, is a macro, but for now we don't have to care: all we need to know is that it tells us the size of whatever we gave it, in this case an int. So when is done, it gives us an address in the heap where we can put an integer. It is important to remember that the data is stored in the heap, while the address of that data is stored in a pointer on the stack.
Posted by: Christiana at January 13, 2004 11:38 AM