I know, I’ve complained about iTunes’s way of organizing files before, but it’s been a while, so here I go again. Why can’t a user simply indicate that such-and-such a disk should be read as though it were an iPod or CD or CD-ROM: that is, as a removable drive from which the main library may read files, but shouldn’t try to add everything to the Über-Archive? So that if I mount a hard drive with some tunes on it, I don’t find missing tunes clogging up my Main Library, or have to wait till iTunes has added all the files to the Main Library? This ought to be a piece of cake, and would make at least one user much happier.
Posted by AKMA at November 15, 2003 07:37 PM | TrackBackWe can see an example of this in our code we've written so far. In each function's block, we declare variables that hold our data. When each function ends, the variables within are disposed of, and the space they were using is given back to the computer to use. The variables live in the blocks of conditionals and loops we write, but they don't cascade into functions we call, because those aren't sub-blocks, but different sections of code entirely. Every variable we've written has a well-defined lifetime of one function.
Posted by: Ottewell at January 12, 2004 07:18 PMWhen Batman went home at the end of a night spent fighting crime, he put on a suit and tie and became Bruce Wayne. When Clark Kent saw a news story getting too hot, a phone booth hid his change into Superman. When you're programming, all the variables you juggle around are doing similar tricks as they present one face to you and a totally different one to the machine.
Posted by: Lancelot at January 12, 2004 07:18 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: Sybil at January 12, 2004 07:18 PMThis will allow us to use a few functions we didn't have access to before. These lines are still a mystery for now, but we'll explain them soon. Now we'll start working within the main function, where favoriteNumber is declared and used. The first thing we need to do is change how we declare the variable. Instead of
Posted by: Conrad at January 13, 2004 09:56 AMWhen a variable is finished with it's work, it does not go into retirement, and it is never mentioned again. Variables simply cease to exist, and the thirty-two bits of data that they held is released, so that some other variable may later use them.
Posted by: Alice at January 13, 2004 09:56 AMFor this program, it was a bit of overkill. It's a lot of overkill, actually. There's usually no need to store integers in the Heap, unless you're making a whole lot of them. But even in this simpler form, it gives us a little bit more flexibility than we had before, in that we can create and destroy variables as we need, without having to worry about the Stack. It also demonstrates a new variable type, the pointer, which you will use extensively throughout your programming. And it is a pattern that is ubiquitous in Cocoa, so it is a pattern you will need to understand, even though Cocoa makes it much more transparent than it is here.
Posted by: Salamon at January 13, 2004 09:56 AM