* converts a pointer to a function to a function designator.
Function designators, including both function names and the result of *, are always converted to pointers to functions unless sizeof or & are involved - the same idea as array objects.
The function call operator always applies to pointers to functions, even when there's no explicit use of function pointers going on.
Still, you don't have to take advantage of any of this stuff to write bizarro code with extra asterisks if you don't want to - many people get by without knowing it. So unless you're specifically looking into how the language works I don't see how it leads to confusion.
OK, so in some cases * has an effect which is then silently undone by the context.
In normal (non-function pointer) use, * has a clear meaning, convert foo* to foo by dereferencing, and it doesn't get randomly undone.
It's confusing because a casual user can't tell whether the * matters or not. By experiment one can tell that in that particular place it doesn't seem to, but why? It matters pretty much everywhere else one might put it. I was left wondering things like "Is there some subtle semantic difference that means it would matter in certain situations?"
I agree this is a bit annoying. When I teach people about C pointer syntax my usual approach is to start by pretending ("lies-to-children") that functions and function pointers are clearly distinct, so that you have to explicitly dereference a function pointer as (*f)(args) when calling it and explicitly use & when taking the address of a function, and so that the "declaration mimics use" maxim continues to make sense even in the case of function pointers. After I'm confident they understand it all on that level, then I mention that there's an additional layer of syntactic sugar which allows you to miss out most of the tedious punctuation when using function pointers. This usually works.
(no subject)
Date: 2006-04-11 10:17 am (UTC)* converts a pointer to a function to a function designator.
Function designators, including both function names and the result of *, are always converted to pointers to functions unless sizeof or & are involved - the same idea as array objects.
The function call operator always applies to pointers to functions, even when there's no explicit use of function pointers going on.
Still, you don't have to take advantage of any of this stuff to write bizarro code with extra asterisks if you don't want to - many people get by without knowing it. So unless you're specifically looking into how the language works I don't see how it leads to confusion.
(no subject)
Date: 2006-04-11 10:25 am (UTC)In normal (non-function pointer) use, * has a clear meaning, convert foo* to foo by dereferencing, and it doesn't get randomly undone.
It's confusing because a casual user can't tell whether the * matters or not. By experiment one can tell that in that particular place it doesn't seem to, but why? It matters pretty much everywhere else one might put it. I was left wondering things like "Is there some subtle semantic difference that means it would matter in certain situations?"
(no subject)
Date: 2006-04-11 11:23 am (UTC)