Why do so many style guides mandate spaces for indentation?
NYTimes Objective–C Style Guide
41–50 of 51 posts
Re: NYTimes Objective–C Style Guide
#42Why do so many style guides mandate spaces for indentation?
the right way to use tabs (tabs for indentation, spaces for alignment) needs some amount of discipline to get right always. It's more flexible but very easy to make a mistake and mess it up.
Re: NYTimes Objective–C Style Guide
#43It's strange that NYT seems to be transitioning to a full blown tech company. Good strange though.
Re: NYTimes Objective–C Style Guide
#44Earlier quoted context omitted.
Given the numerous advantages of int* a; rather than int a;, and the general laziness of declaring variables together anyway, wouldn't it be more reasonable, as a house style, to require int and to disapprove the declaration of multiple variables in the same statement?
Note: using % instead of * below because I can't for the life of me figure out how to type an asterisk without it being used as an italics markup directive. >> Given the numerous advantages of int% a; rather than int %a; Care to elaborate what 'numerous advantages' there are to use int% a instead of int %a, because I can't think of a single one besides 'it feels more natural', which IMO is irrelevant in the context o…
Re: NYTimes Objective–C Style Guide
#45why not provide a post-commit hook enforcing a lot these styles?
Re: NYTimes Objective–C Style Guide
#46They seem to have an en dash between Objective and C which made me misparse the title. Surely that's not in their style guide?
Re: NYTimes Objective–C Style Guide
#47> Asterisks indicating pointers belong with the variable, i.e. NSString text not NSString text or NSString * text, except in the case of global string constants. I know I have it wrong, but I always feel that the the variable is of type "pointer to type" so isnt it fairer to have the asterisk paired with the type denoting it is of the kind "pointer to type"?
i used to think like you do, but this changed my mind; int *a; is saying, when you dereference a, you have an integer. and when you think about it - a pointer is the same length for any data type, even pointers to functions, so it would be pointless to have a different pointer type for each data structure.
No that's not guaranteed despite being common. And function pointers are not even guaranteed to be representable by void* (POSIX08 does mandate it though.)
Relevant sections of the standard here http://stackoverflow.com/a/3941867/1546653
Re: NYTimes Objective–C Style Guide
#48Earlier quoted context omitted.
Given the numerous advantages of int* a; rather than int a;, and the general laziness of declaring variables together anyway, wouldn't it be more reasonable, as a house style, to require int and to disapprove the declaration of multiple variables in the same statement?
Note: using % instead of * below because I can't for the life of me figure out how to type an asterisk without it being used as an italics markup directive. >> Given the numerous advantages of int% a; rather than int %a; Care to elaborate what 'numerous advantages' there are to use int% a instead of int %a, because I can't think of a single one besides 'it feels more natural', which IMO is irrelevant in the context o…
Re: NYTimes Objective–C Style Guide
#49> Asterisks indicating pointers belong with the variable, i.e. NSString text not NSString text or NSString * text, except in the case of global string constants. I know I have it wrong, but I always feel that the the variable is of type "pointer to type" so isnt it fairer to have the asterisk paired with the type denoting it is of the kind "pointer to type"?
That's how it feels, but the syntax for declaring multiple variables breaks it: int* a, b; is equivalent to int *a; int b; not int *a; int *b; So while I think it makes sense to think of the pointer nature as part of the type I stopped using it as the risk of writing incorrect code was too great. Though there's also the option of forbidding shorthand declaration. Then you can write int* a; int* b; especially if you h…
Re: NYTimes Objective–C Style Guide
#50Why do so many style guides mandate spaces for indentation?