N
Nick
I'm not after a definitive answer here - I know there aren't any. But
I'm curious to know how people feel about something.
A few days ago I found myself writing something like this:
find_item(name)->identifier
Where find_item looks up a name in a data structure and returns a
pointer to the node (a struct). The "identifier" is an integer.
I was, in fact, using this as a paramater to another function, that took
an integer identifier and did some more stuff with it.
There's a bit of me that thinks this is really neat, and another bit of
me that found the resulting three-line statement horrible.
In the end I realised I needed different items at different times, so
introduced a temporary variable. But how do others feel about this
idea of getting a struct pointer back from a function and extracting a
member directly from it?
I'm curious to know how people feel about something.
A few days ago I found myself writing something like this:
find_item(name)->identifier
Where find_item looks up a name in a data structure and returns a
pointer to the node (a struct). The "identifier" is an integer.
I was, in fact, using this as a paramater to another function, that took
an integer identifier and did some more stuff with it.
There's a bit of me that thinks this is really neat, and another bit of
me that found the resulting three-line statement horrible.
In the end I realised I needed different items at different times, so
introduced a temporary variable. But how do others feel about this
idea of getting a struct pointer back from a function and extracting a
member directly from it?