struct masquerading as an array?
struct masquerading as an array?
- Subject: struct masquerading as an array?
- From: email@hidden
- Date: Fri, 11 Mar 2005 22:53:48 -0600
This is really more of a C question, but can I legitimately replace:
id args[4];
[array getObjects:args];
if ([args[0] evaluate:args[1]]) ...
with:
struct {
id parser;
id condition;
id trueExpr;
id falseExpr;
} args;
[array getObjects:&args];
if ([args.parser evaluate:args.condition]) ...
The reason is that the readability of "args.condition" is better than
"args[1]". Using macros or enums for the indices could accomplish the
same readability goal, but the indices are context sensitive which
would lead to a plethora of permutations of enums/macros.
I can't see why the C compiler would align an array of pointers
differently than a struct of pointers. I do suppose I'm making the
gross assumption that getObjects: is more efficient than n-many calls
to objectAtIndex:. Any advice?
Daryn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden