Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: sizeof() confusion Message-ID: <1990Nov17.041345.7158@zoo.toronto.edu> Organization: U of Toronto Zoology References: <2665@cirrusl.UUCP> <2692@cirrusl.UUCP> <1990Nov14.154213.27324@cbnewsj.att.com> <14462@smoke.brl.mil> <1990Nov16.141352.22426@dce.ie> Date: Sat, 17 Nov 90 04:13:45 GMT In article <1990Nov16.141352.22426@dce.ie> ch@dce.ie (Charles Bryant) writes: >> there are two distinct uses of sizeof: >> sizeof unary_expression >> sizeof ( type_name ) > >That must make parsing it more difficult than if the parentheses were always >required: > sizeof (type_name) - 1 >since in other contexts "(type_name) - 1" would be an expression containing >a cast. Requiring parentheses wouldn't make any difference, since it's still legal to wrap a unary expression in parentheses, so you can't tell from the opening parenthesis which form is coming. What *would* be useful is if casts began with something that *couldn't* begin a unary expression. As it is, either you need to sneak a peek a bit further ahead, or you get to write some contorted code that swallows the parenthesis and then decides, based on the next token, whether it has cast-minus-leading-paren or parenthesized-expression-minus-leading-paren. Definitely a nuisance, and it's not the only such case in C. -- "I don't *want* to be normal!" | Henry Spencer at U of Toronto Zoology "Not to worry." | henry@zoo.toronto.edu utzoo!henry