Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: double free Date: Tue, 12 Jul 2016 09:08:22 -0700 Organization: None to speak of Lines: 55 Message-ID: References: <57837892.8808984@news.xs4all.nl> <481f30b4-acb3-4445-92b3-c403dc3e51f7@googlegroups.com> <8760sc2aiz.fsf@bsb.me.uk> <87twfv26cv.fsf@bsb.me.uk> <2cfb31aa-11dd-422c-a5ea-07f44bee0deb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="10518"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/tQ+ESywvfSzJAoNOwG5nV" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:QjPOXpotI4OsEPGU41Yydc3vFdI= sha1:0UjdsSi0ByJcJXejgJKjOtjQ8pI= Xref: csiph.com comp.lang.c:90276 David Brown writes: [...] > I think it makes it clearer that you are taking a particular operation, > "sizeof", and applying it to the thing inside the brackets. Do you use parentheses on a return statement with an expression? `return expr;` is a statement, not an expression, but I think the same considerations apply. Writing `sizeof(n)` rather than `sizeof n` makes it look too much like a function call, which it isn't. Writing `return(n);` rather than `return n;` makes it look too much like a function call, which it isn't. Both sizeof and return are keywords, not ordinary identifiers. For C or just about any other language, I find it easier to read and understand code if I think of keywords as distinct syntactic entities, not as identifiers. Given these symbols: foo sizeof & I personally find `sizeof` more similar to `&` than to `foo`, because `sizeof` and `&` are both special symbols whose meaning is defined by the language, while `foo` is an identifier whose meaning is defined by an explicit declaration. > I will happily admit that this is a matter of personal taste or > preference (hence the "IMHO") - unfortunately that also makes it > difficult to explain. But it feels "natural" to have parenthesis here. > On the other hand, in some places where C insists on parenthesis, such > as "if (x)", the parenthesis feel unnecessary. Actually the parentheses are necessary in that case to avoid ambiguity. If the grammar required `{` and `}`, they wouldn't be. But in C, you need to distinguish between if (x) -1; and if x-1; (There are probably more realistic examples.) In most languages, you have to have something to delimit the end of the condition in an if statement. C-like languages use parentheses; some other languages use a `then` keyword or an end-of-line. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"