Cryptic Syntax

S

Seebs

Rod said:
[The asterisk in (*fptr)()] also presents
a cleaner model of dereferencing.
<aol>
Absolutely.
</aol>

I'm torn on the issue. I like it for clarity, although I don't actually
always use it. I use it when it is part of the perceived interface that
the thing called is being a function pointer, usually. Example: In pseudo,
there's a number of function pointers named "real_foo()"; they are just called
as "real_foo(args)" because, although they happen to be function pointers,
they are not logically "pointers" subject to change -- they're fixed values
which happen to have been computed somewhere close to startup.

By contrast, if I'm doing a table of function pointers, I usually do
"(*foo->fptr)(args)", because it's important to the reader to know that
"fptr" may be any of several functions.

-s
 
B

Ben Bacarisse

Richard Heathfield said:
Rod Pemberton wrote:

[The asterisk in (*fptr)()] also presents
a cleaner model of dereferencing.

<aol>
Absolutely.
</aol>

I think that is true only if you forget what the construct means;
otherwise it seems far from clean. For those people who now think in
"modern" C (i.e. less than 20 years old) it seems odd to dereference
something just so that it can be converted back to a pointer.

In the "new" style (scare quote, because I don't think of things like
void and function prototypes as new anymore) function types are treated
like array types and the [] and () operators both work on pointers
rather than the things to which these pointers point. I think the
result is at least as clean.

I only came to this view about a decade ago -- I was slow to leave the
old meaning behind.
 
B

Ben Bacarisse

Rod Pemberton said:
That's true for old code. It's an error without it, for old code. How is
that misleading? You're describing in terms of the "modern" meaning, and
saying _not_ that the old meaning is misleading or no longer applies, but
that *my* statement is misleading... How warped is that?

We'll have to leave this as a matter on which we can't agree. Your
statement was true of a language that very few people program in
anymore. I think it is misleading to describe the mechanism of function
calling as it was more than 20 years ago. Obviously you don't. Your
statement was once true and is still for anyone who is still using K&R C
so I maybe we can leave it at that. You are not wrong.

<snip>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,104
Messages
2,570,643
Members
47,247
Latest member
youngcoin

Latest Threads

Top