Re: Chinese Syntax

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Justin Rogers (Justin_at_games4dotnet.com)
Date: 05/27/04


Date: Wed, 26 May 2004 17:16:38 -0700

As a long time programmer of many languages I've always found the explicit
statement bounding in C to be quite nice. For me it improves readability as
my seasoned internal tokenizer is capable of finding code blocks more quickly
by using the braces and parenthesis than by scanning whitespace. Whitespace
also breaks down quite fast when you start using non fixed width fonts and
mixing tabs and spaces. Arguably you could say, don't do that, but at least
with something of the nature of C and it's explit block scoping you can easily
write a pretty printer and avoid any ambiguity that would otherwise exist.

Take the following excerpt from a Python tutorial:
Tuple syntax

>From a syntax viewpoint, you create a tuple by placing a sequence of items
inside a pair of enclosing parentheses and separating them by commas. Note that
the parentheses can be omitted when such omission will not lead to ambiguity.

Note that they point out you can leave out parens only when it won't lead to
ambiguity. C doesn't make that mistake. They make sure there is no ambiguity,
and if you leave out a parens it doesn't make the statement ambiguous, it makes
it
a different or erroneous statement altogether.

-- 
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"C# Learner" <csharp@learner.here> wrote in message
news:euOxH13QEHA.3744@TK2MSFTNGP10.phx.gbl...
> Alex Moskalyuk wrote:
>
> > Have you ever looked into Perl or Lisp code?
> >
> > C suddenly starts making perfect sense.
> >
> > What's uneasy to you? Curly braces, parentheses, keywords, or something
> > else?
>
> One of the biggest flaws in C syntax, in my opinion, is the required
> parentheses for test conditions.
>
> Here's a very simple example:
>
>      void Foo
>      {
>          if (FooBar(Parse(Process(GetInput())))
>              DoSomething();
>      }
>
> Imagine if, instead, we could write the following:
>
>      void Foo
>      {
>          if FooBar(Parse(Process(GetInput())):
>              DoSomething();
>      }
>
> Python uses such a construct for test conditions.
>
> Another nicety about Python is the fact that whitespace is used for
> defining code blocks.  This makes code much clearer than the equivalent
> C code, which requires block being/end markers.
>
> Here's a very simple Python code sample:
> http://www.kernelthread.com/hanoi/html/py.html .
>
> Try staring at it for one minute.
>
> After having done so, take a look at this:
> http://www.kernelthread.com/hanoi/html/c.html .
>
> Even if one's accustomed to C syntax, the former is still clearer and
> easier-to-read, don't you think?
>
> Every time I see code that conforms to C's basic syntax, I cringe; yet I
> write such code every day.
>
> Why C?  Why?!


Relevant Pages

  • Re: Chinese Syntax
    ... the parentheses can be omitted when such omission will not lead to ambiguity. ... > One of the biggest flaws in C syntax, in my opinion, is the required> parentheses for test conditions. ... > Python uses such a construct for test conditions. ...
    (comp.lang.c)
  • Re: Why == ??
    ... C/C++ or Java should be located across the internet. ... - The Zen of Python, ... syntax options were crap. ... its ambiguity from the point of view of a C/C++ programmer. ...
    (comp.lang.python)
  • Re: Chinese Syntax
    ... Curly braces, parentheses, keywords, or something ... One of the biggest flaws in C syntax, in my opinion, is the required ... Python uses such a construct for test conditions. ... This makes code much clearer than the equivalent ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Chinese Syntax
    ... Curly braces, parentheses, keywords, or something ... One of the biggest flaws in C syntax, in my opinion, is the required ... Python uses such a construct for test conditions. ... This makes code much clearer than the equivalent ...
    (comp.lang.c)
  • Re: Why tuple with one item is no tuple
    ... As I said: show me which parentheses to use - and keep in mind that: ... - unicode surely features some usable characters (e.g. the quotation markes ... > no way to have both operators in a natural way in python. ... Which would reintroduce the ambiguity ...
    (comp.lang.python)