Python-like tabs instead of curley brackets?

Daniel Keep daniel.keep+lists at gmail.com
Sun Dec 3 14:12:42 PST 2006


>>Or this:
>>
>> > FunkyThing(some_expression,
>> > {
>> > 	<< More Code >>
>> > });
> 
> You can, or we can adapt backslash (like in bash) to do this:
> FunkyThing(some_expression, \
> { \
> 	<< More Code >> \
> }); \
> 
> I know, it is awful. Another proposition can be:
> Implicit { introduce additional indentation level inside.
> So it will be like:
> FunkyThinkg(some, \
> {
>    xx
>    if y:
>      z
> })
> 

So if curly braces are unneccesary and nothing but syntactic noise... 
then why are you using them, and then having to invent hacks to get 
around the fact that you're relying on indentation?

The fact that you're having to compensate for their absense obviously 
means they aren't redundant :3

> 
>>P.S.  Just so you know, I love Python's syntax.  I just don't think
>>it's suitable for D. :)
> 
> I also like Python's syntax, but i think small portion of D can be
> adapted to this syntax (if anyone like tabs, and if it will be used
> by anyone). I also think that people frustrated by Python syntax,
> simply have bad editor/configuration. Lots of editors now is not tabaware.
> 
> PS. I use in all languages (Python, C, D, etc.) hard-tabs (for
> indentations), which are displayed as 4-character in my
> editor. There are simple rules to be consistent with such style, and not
> introduce problems in any situation.

And there's another problem with Python's syntax: I hate *hard* tabs. 
Absolutely loathe them; they continuously get displayed as 8 spaces when 
I damn well want them to be 4 spaces.  And some hideously misguided 
fools display them as *2* spaces!  Those sick, sad people... (joking)

I worked on a project in my third year of uni with four other people. 
Things were going swell until files started breaking.  Stuff would just 
stop compiling from svn suddenly.

It turned out that one of the guys was using a MODERN editor that simply 
couldn't cope with the rigors of Python: specifically, he liked hard 
tabs but everyone else was using soft tabs.  The editor started changing 
bits and pieces of our code from soft to hard, and broke tons of stuff. 
  It was really bad when it would combine soft and hard tabs in places 
into something that looked valid on HIS machine, but totally borked on 
ours.  And since Python has nothing bar indentation to signify nesting, 
it was a painful job to fix it all up manually.

He complained bitterly that it was a pain to have to continually 
reconfigured his editor to support our coding style.  And he was damn 
right, too--some say "get a better editor", but he shouldn't *have* to. 
  He chose his editor for good reasons, and it's not fair to force 
people to change because you think their editor sucks.

(Incidentally, I use IDLE for Python coding and GVim for everything 
else.  I guess I just didn't mind so much.)

In the end, we just kept having to "sanitise" his files every once in a 
while, especially when someone else had to work on them.

I am, once again, rambling.  :)

In any case, you mention converting a "small portion of D"... I think 
that if you boiled down D to a simple, indentation-based language... 
you'd end up with Python anyway :P  If you're really set on compiling it 
to native, I recommend checking out Pyrex.

	-- Daniel



More information about the Digitalmars-d mailing list