Hi Ian,

On 2026-01-28T21:46:14+0000, Ian Collier via Mutt-dev wrote:
> On Wed, Jan 28, 2026 at 10:08:37PM +0100, Alejandro Colomar via Mutt-dev 
> wrote:
> > On 2026-01-28T15:46:08-0500, Derek Martin wrote:
> > >   - sizeof IS NOT A FUNCTION[*]. Do not format it like one
> 
> > For consistency, it is better to always use parens, since you need them
> > in half of the cases.
> 
> I disagree.  The parens actually tell you whether the argument is a type
> or a variable.

This is not true.  Consider the following counter-example:

        sizeof(int)1

This is equivalent to sizeof((int)1), not (sizeof(int))1 --which would
be a syntax error, BTW--.  Thus, you have parentheses with an
expression, not a type.

Another counter-example (C99):

        sizeof(int){1}

This is parsed as sizeof((int){1}), not as (sizeof(int)){1} --which
would be another syntax error--.


Have a lovely night!
Alex

> The parens, as I'm sure you know, are used because the
> argument of the 'sizeof' operator can be a type-cast, and parens are
> part of the type-cast syntax.  Let's not mix them up with parens that
> are part of the function-call syntax.
>
> For that reason, if I were writing code now* I might put a space after
> 'sizeof' whereas I never put a space between a function and its arguments.
> 
> > Operators not requiring parentheses complicate parsing in compilers and
> > is a historic accident that can't be removed
> 
> 'Accident' is a matter of opinion, but in any case I would argue that
> this is entirely irrelevant to how one decides to write C syntax -
> because we're writing to the syntax that exists, not the syntax
> that could exist or the syntax that might have made the compiler
> less complicated if it had been designed differently.
> 
> imc
> 
> * There's plenty of code from my past where I typed as few spaces as
> possible, so you will find lots of places where I might have typed
> 'sizeof(int)'.  But also some places where I typed 'sizeof i' because
> the space is required in that case.

-- 
<https://www.alejandro-colomar.es>

Attachment: signature.asc
Description: PGP signature

Reply via email to