And then I was 13 again

Since Monday (27), my mum is in Sydney to know the city and see her son. Since then, we are doing laps around CDB (where her hotel is) and Sydney Harbour (where the Opera House is) and, sometimes, Darling Harbour (where the Aquarium is.)

But yesterday we broke the cycle and went to Taronga Zoo, in the other side of the Harbour. It was something I was planing to do for some time already, but never really got into getting a ferry and going there. Always, there was something else to do.

One thing about my mum: She’s almost 60, but she’s a “professional walker.” She can walk for hours without a problem. Me, I’m a professional cyclist. I’m terrible walking. Just to let you know, one the first day, my right leg was killing me just after the first day. On the second day, it was both legs and my back. Yesterday, it was the legs and feet.

But even with all that pain, when we got there, I absolutely, with no exceptions, had to see everything. We got a map and I got a pen and was checking every animal I saw.

(In case you’re wondering, the map shows the whole Zoo, with small icons showing where you can find the animals.)

If I knew I’d have so great time there, I’d go there soon. Obviously, now I want to go there again, to see the shows. We managed to only see the birds show, which is really amazing, with birds flying just above your head, in open air.

So, if you are around Sydney and, even if you don’t like animals that much, go to the Zoo. Also, drop me a note, so I can go with you. ;)

PS: Pics coming soon.

The multiple faces of nothing

[… or “C, variants and the NULL”]

In C, you have a way to represent nothing. It’s NULL (all caps). NULL points to nowhere and it’s defined as “0”. Why would someone use it? Well, if you have a list and some of the elements aren’t valid, you make them NULL. Since NULL is not a valid pointer, your application will crash if you try to access it. The whole point of NULL is to provide a way to represent the nothing. There is also a nothing type “void”, which you can define anything statically, but you can make it a point of it. Since all pointers have the same size, a “void pointer” is, basically, a pointer to anything.

Also, C have the idea of “nul-terminated strings” (yes, with just one “l”.) the “nul” character is represented by “\0”, which, in practical terms, is a space of memory with the size of a “char” with the value 0 on it.

When going down to the very bits of NULL and nul, they go almost the same, except for their size.

C++ was build on top of C, but if defined NULL as a pointer pointing to the byte 0. It’s almost the same thing as the C NULL but, because it’s a pointer, it doesn’t need to be converted when you’re using a CPU which have a different size for “int”s and pointers (usually, pointers are “long int”s or even more, if your CPU have more than 64 bits.)

Objective-C is a variant of C adding support for objects in a different way and the biggest “user” of Objective-C is Apple. The Apple version of Objective-C provides some basic types like lists. But, because you can’t leave an empty space in the list (which I think it similar to the way we deal with nul-terminated string), they created a NSNull object, which is a valid object, but it represents the null (which, by the way, are called “nil” in Objective-C.) It’s not an invalid memory address, as it points to a real object. The NSNull object provides just one method, “null” which returns a “nil” pointer (are you confused already?)

Now, the fun part: Most list (dictionaries actually, but the process is almost the same) operations, when you try to access an object that doesn’t exist, returns nil. But remember that the only way to leave an empty spot in a list is adding a NSNull object. So, to be really sure that something is not there, you need to check if the result is “nil” or “not an [NSNull null]”.

That’s too much stuff for nothing…

links for 2008-10-23