Re: [dev] [sic] [patch] const-correctness and formalities

2013-08-22 Thread Roberto E. Vargas Caballero
Declaring immutable arguments makes reading the code easier. Depends of the eyes, for me, const only adds noise to the code and it should be avoid except in some situations. In the case of main is directly an error because the standard says explicityly that main must be defined as:

Re: [dev] [sic] [patch] const-correctness and formalities

2013-08-22 Thread FRIGN
Hey sin, thanks for your feedback! -static char * -eat(char *s, int (*p)(int), int r) { +static char* +eat(char *s, int (*p)(int), const int r) { while(*s != '\0' p(*s) == r) s++; return s; } Please do not use char* instead use char *. I'm puzzled.

Re: [dev] [sic] [patch] const-correctness and formalities

2013-08-22 Thread FRIGN
Declaring immutable arguments makes reading the code easier. Depends of the eyes, for me, const only adds noise to the code and it should be avoid except in some situations. In the case of main is directly an error because the standard says explicityly that main must be defined as:

Re: [dev] [sic] [patch] const-correctness and formalities

2013-08-22 Thread sin
+eat(char *s, int (*p)(int), const int r) { `const int r' also does not make much sense. This is not idiomatic code. +skip(char *s, const char c) { Similarly here for `c'. I'd expect this to be simply an int to be honest. Thanks, sin

Re: [dev] [sic] [patch] const-correctness and formalities

2013-08-22 Thread Roberto E. Vargas Caballero
On Thu, Aug 22, 2013 at 12:15:23PM +0300, sin wrote: +eat(char *s, int (*p)(int), const int r) { `const int r' also does not make much sense. This is not idiomatic code. I agree with you. Since r is a local variable doesn't matter if the function modifies it (and even is better modify it

Re: [dev] [sic] [patch] const-correctness and formalities

2013-08-22 Thread Ralph Eastwood
On 22 August 2013 10:58, Roberto E. Vargas Caballero k...@shike2.com wrote: Since r is a local variable doesn't matter if the function modifies it (and even is better modify it instead of using other local variable for it). I use const only when I want show that the function is going to

[dev] [sic] [patch] const-correctness and formalities

2013-08-21 Thread FRIGN
util.c --- util.c 2013-08-21 20:53:34.774661860 +0200 +++ util.c 2013-08-21 17:58:22.327780012 +0200 @@ -17,7 +17,7 @@ } static int -dial(char *host, char *port) { +dial(const char *host, const char *port) { static struct addrinfo hints; int srv;

Re: [dev] [sic] [patch] const-correctness and formalities

2013-08-21 Thread sin
-static char * -eat(char *s, int (*p)(int), int r) { +static char* +eat(char *s, int (*p)(int), const int r) { while(*s != '\0' p(*s) == r) s++; return s; } Please do not use char* instead use char *. int -main(int argc, char *argv[]) { +main(const