Wanted for abuse of operators
From the stock app delegate in Apple’s Core Data application template:
[managedObjectContext release], managedObjectContext = nil;
[persistentStoreCoordinator release], persistentStoreCoordinator = nil;
[managedObjectModel release], managedObjectModel = nil;
And in case you were wondering how Apple could possibly ship code that doesn’t even compile in the app templates…
… that’s legal code.
Yes, there is a comma operator, and that’s what’s at work there. There is a warning (-release returns void, whereas assignment of nil returns id, so the types are mismatched, which GCC doesn’t like), but the code is legal.
Legal doesn’t always mean correct, however. The comma operator is supposed to be used for things like this:
printf(“%s\n”, (--argc, *++argv));
Though in modern usage it is out of favor, replaced on sight with less obfuscative code:
printf(“%s\n”, *++argv);
--argc;
printf(“%s\n”, argv[idx++]);
It is not for performing a void function call followed by an assignment. A void expression should never appear in a comma expression. The code would be greatly improved by replacing the comma with a semicolon, dividing each statement into the two statements that it should be.
December 2nd, 2006 at 16:03:17
This is completely off-topic but I can’t get Vienna to read your feed. It says “Error parsing XML data in feed.” Yours is one of only two I found that do this. The feed validator suggests there’s perhaps a minor issue?
December 2nd, 2006 at 16:29:03
Guess it didn’t like my declaration at the top of the file. I find nothing in the XML spec to suggest that it’s illegal, but xmllint doesn’t like it, and apparently neither does Vienna.
I’ve commented it out, although the feed still doesn’t validate because entity references outside of the standard five are not declared.
December 2nd, 2006 at 16:36:25
Yargh!
my <!ENTITY> declaration.
December 2nd, 2006 at 16:56:38
Well, the feed is read by Vienna now, but the excerpts are empty. Just article titles.
December 2nd, 2006 at 16:59:11
I take that back. The feed is parsed enough for Vienna to get a list of articles, but the excerpts are empty — just titles.
December 2nd, 2006 at 17:30:44
Works now. I had some borken XML in the previous post (unmatched “” in attribute values).
December 13th, 2006 at 21:17:30
You didn’t mention how cool the comma operator is when used in a #define to specify a return value. I just learned about that recently. Sorry to post something on-topic :P
December 14th, 2006 at 15:06:31
Yes, the comma operator does have cool and correct uses. This wasn’t one of them. ;)