Also, whitespace based indentation works in Python because Python statements tend to be fairly short. (The python indentation rules are easily understood.) Haskell layout has been somewhat more difficult to understand (at least for me). I have been writing Haskell code and usually it works, but there have been problems due to failure to indent when I should'v, which were incredibly confusing to debug.
In python, it's hard to fuck it up: after a colon, you always newline and indent.
But what about:
if True: print "Yep"
;)if True: print("Yep")
Some features of Python are only really meant to be used at interactive prompts, like import STAR ( I can't write star?)
virtual const std::string& getCommand() const throw() { return m_command ; }
For example, I recently needed to do some Run-Length Encoding:
import Control.Arrow
import Data.List
encodeRLE :: (Eq a) => [a] -> [(Int, a)]
encodeRLE = map (length &&& head) . group
decodeRLE :: [(Int, a)] -> [a]
decodeRLE = concatMap (uncurry replicate) if tyrant:
divide(); conquer()
is possible. Mixing curly braces with Python-style though wouldn't be very nice, I think.Indentation-as-a-divider is definitely easer on the eye than curly braces. But C-stlye has some handy bits and pieces to pick up (expecially on the OOP side of things - and also in the type-setting; though that has improved in python)
I find superlong indented blocks in Python a bit awkward, although can't explain why. When I look at a long class definition, for example, it just begs to be closed with end or "}". Small blocks though look definitely better without the block braces.
I'm thinking about introducing an optional end and leaving it to the taste of a programmer. Not sure yet.
def something:
alpha()
omega()
#end
I think introducing it as a special case, with no semantic value, into your parser would be an extremely poor idea. def something:
...
end def
but then it makes indentations insignificant altogether.I can't say I'm a fan, but at least you'd be making it mean something if you did that.
(Also: why make it optional at that point? Seems like it should be required for simplicity's sake)
It would be nice, however, to have some optional verification mechanism that allowed you to stay minimalist for as long as you wish, and to use closing tags for verification and/or aesthetical reasons - for example, when closing a superlong block.
My point with braces is that you dont have to indent the code then - which is dangerous :)
I have inherited a couple of PHP and C projects that have taken weeks just to indent to be readable - before i can even begin to work on them! (admittedly that is more of a PHP problem). Forced indentation makes definite that everything is obvious: addign curly braces is purely asthetic IMO :D
(defun indent-buffer ()
"Indent entire buffer"
(interactive)
(indent-region (point-min) (point-max) nil))
- It is easier on the eye, especially when somone else has to read through & understand it
- I find it quicker to code
That said there are some aspects where C-style is superior - so a combination of the 2 might work well! Invent your own "mash up" style (as long as it is not too confusing).