Silly brackets (Was: Re: Problems extending Python with C.)

Martin v. Loewis martin at loewis.home.cs.tu-berlin.de
Sun Feb 20 16:37:41 EST 2000


> I would not think it is a problem, as #define's all expand into one line,
> and there is nothing to report about brackets which match on the same line.
> Could you provide an example of pre-processor breaking user indentation?

It depends on the exact rules you impose. Consider

#define foo(x)         x
int main()
{
  bar();
  foo(4);
}

After preprocessor, I get

# 1 "a.c"

int main()
{
  bar();
   4  ;
}

In the Python sense of indentation, the second line is not aligned
with the previous one, so it is incorrectly indented.

Suppose you'd implement such a feature: How exactly would you define
'correct indentation'? Probably you'd consider the position of the
closing bracket. Must that be

a) in the same column as the opening one?
b) aligned with the keyword starting the block?

Would you check anything else? I.e. what magic would find the
often-quoted

  for (i=0;i<10;i++);
    printf("%d\n",i);

Regards,
Martin




More information about the Python-list mailing list