Python-like tabs instead of curley brackets?

Daniel Keep daniel.keep+lists at gmail.com
Thu Nov 30 21:33:05 PST 2006


Witold Baryluk wrote:
> Dnia Fri, 27 Oct 2006 12:15:48 +0000 (UTC)
> Charles Fox <charles at SPAMMENOT.robots.ox.ac.uk> napisał/a:
> 
> 
>>I've been following D for a few years now, and I'd like to suggest
>>ditching the (now completely redundant) curley brackets from the
>>C-like syntax and borrowing Python's use of tabs to replace them.   I
>>see no reason to keep the curley brackets now we have nice editors
>>that know about (and can display) tab characters.  The ideal
>>programming language should have no redundancy, you shouldn't have to
>>say anything twice, and at present we are still repearting ourselves
>>with both curley brackets and indentation!  What do you think?
> 
> 
> Hi all.
> 
> Try this:
> http://smp.if.uj.edu.pl/~baryluk/d/dmt-1.0.tar.gz
> 
> Note: not tested well (it is very simple and naive, but can be used for
> tests. but to be usefull some issues should be resolved in future).
> 
> 
> --
> Witold Baryluk
> MAIL: baryluk at smp.if.uj.edu.pl, baryluk at mpi.int.pl
> JID: movax at jabber.autocom.pl

Question: how do you propose to do these with only indentation:

 > extern(C):
 > << Butt-loads of non-indented code because indenting a whole file four
 >    spaces is stupid >>

Or this:

 > FunkyThing(some_expression,
 > {
 > 	<< More Code >>
 > });

(Walter, can we *pretty please* have trailing delegate literals? 
*puppy-dog eyes*)

Or even THIS (which Python to this day cannot do):

 > do
 > {
 > 	<< code >>
 > }
 > while( expression );

There's no way to indent the above that makes sense.

You say that we are repeating ourselves with indentation and curly 
braces... but that's not always true.  Take the following:

 > class Foo
 > {
 > public:
 > 	<< Public members >>
 >
 > private:
 > 	<< Private members >>
 > }

Here I'm *not* repeating myself.  I'm deliberately altering the 
indentation because losing eight characters on the side of every line of 
code just to make room for access modifiers is stupid.  Here's another 
real-life example:

 > for( int i=0; i<WIDTH; i++ )
 > for( int j=0; j<HEIGHT; j++ )
 > {
 > 	<< Code >>
 > }

I've broken convention there to emphasise that this is a 2D traversal 
across a rectangular array.

The curly brace syntax is NOT redundant.  It's just different.  Please 
stop being syntaxist -- all syntaxes are created equal!

... except for APL.  That's like vomiting random unicode code points 
onto a piece of paper and calling it code.  Oh, and LISP.  But then, 
that's not really a syntax so much as a file format for S-expressions 
that happens to be executable :3

	-- Daniel "has far too many 2c coins lying around"

P.S.  Just so you know, I love Python's syntax.  I just don't think it's 
suitable for D. :)



More information about the Digitalmars-d mailing list