In C, why is the * operator both reference and type casting?
tmsh: I imagine the rationale was something like: how do we indicate that types are references to memory? Let's be concise and use the asterisk after the type of the memory.How do we dereference an address? Since it only makes sense that types with an asterisk will be dereferenced, let's use an asterisk like we did in the type declaration. There, we have uniformity.Oh wait, f-. What about if we want the address of something on the stack? Oh, maybe use the ampersand, and then that returns a pointer just like a pointer to something on the heap. Awesome! Let's even extend that ampersand to return the address of anything. Dereferenced pointers. What have you.And yet, it's not completely symmetrical. Hence, pointers not being completely intuitive.In addition, the ampersand as 'reference' is another completely unrelated syntax convenience. Which of course makes the language even slightly less symmetrical.But, once you understand exactly what it's doing -- and your mind will adapt until it seems completely intuitive -- it is quite concise.But the trick is that it's not concise like s-expressions. There's no clear symmetry. A lot of C (and even more C++) is simply syntax.