FROM : Jean-Daniel Dupas
DATE : Sun Apr 20 11:45:15 2008
Le 20 avr. 08 à 01:03, Uli Kusterer a écrit :
> Am 19.04.2008 um 18:46 schrieb Jerry Krinock:
>> I often write methods that take an (NSError**)error_p argument. In
>> the documentation of Apple methods that do this, I read that the
>> NSError** will be set if there ^is^ an error, but most do not
>> specify what will happen if there is ^not^.
>
>
> Well, when Apple code doesn't specify it will be set to NIL, one
> can't rely on that, so definitely rely on the return value for those.
>
> However, when I write my own code, I like to set the error variable
> on NIL to indicate no error, because that's just better style. Then
> again, I also initialize list counters in code like:
>
> int x = 0;
> for( x = 0; x < maxCount(); x++ )
> ;
>
> Simply because you'll never know who is going to insert their own
> code between those two lines and re-use x. Even if you work alone,
> you may screw up two years from now.
I greatly prefere the C99 way to do it. It prevents variables conflict
if you have more than one loop in your method.
for (int idx = 0; idx < maxCount(); idx++) {
}
DATE : Sun Apr 20 11:45:15 2008
Le 20 avr. 08 à 01:03, Uli Kusterer a écrit :
> Am 19.04.2008 um 18:46 schrieb Jerry Krinock:
>> I often write methods that take an (NSError**)error_p argument. In
>> the documentation of Apple methods that do this, I read that the
>> NSError** will be set if there ^is^ an error, but most do not
>> specify what will happen if there is ^not^.
>
>
> Well, when Apple code doesn't specify it will be set to NIL, one
> can't rely on that, so definitely rely on the return value for those.
>
> However, when I write my own code, I like to set the error variable
> on NIL to indicate no error, because that's just better style. Then
> again, I also initialize list counters in code like:
>
> int x = 0;
> for( x = 0; x < maxCount(); x++ )
> ;
>
> Simply because you'll never know who is going to insert their own
> code between those two lines and re-use x. Even if you work alone,
> you may screw up two years from now.
I greatly prefere the C99 way to do it. It prevents variables conflict
if you have more than one loop in your method.
for (int idx = 0; idx < maxCount(); idx++) {
}
| Related mails | Author | Date |
|---|---|---|
| Jerry Krinock | Apr 19, 18:46 | |
| Bill Bumgarner | Apr 19, 20:24 | |
| Jerry Krinock | Apr 19, 22:10 | |
| Ali Ozer | Apr 20, 00:11 | |
| Uli Kusterer | Apr 20, 01:03 | |
| Jean-Daniel Dupas | Apr 20, 11:45 | |
| Uli Kusterer | Apr 20, 16:20 | |
| Clark Cox | Apr 20, 17:40 |






Cocoa mail archive

