4 ms·
how about take a page from haskell style syntax, which allows both inferring the block structure from indentation, but also always it to be explicitly denoted a
by carterschonwald 18y ago
how about take a page from haskell style syntax, which allows both inferring the block structure from indentation, but also always it to be explicitly denoted at well?
- FalconNL 18y agoCompletely agree. The main reason for my preference is that one of the things I hate most in C-style languages is that one-line functions take up three or four lines (depending on whether or not you use K&R style). This greatly increases the amount of scrolling you have to do.
- mdakin 18y agoPut it all on one line then! :) I just grepped some of my C/C++ code and my one-liners consistently look like this: virtual const std::string& getCommand() const throw() { return m_command ; }
- FalconNL 18y agoYeah, that works for really short methods, but for anything even a little more complex you're just replacing vertical scrolling with horizontal scrolling.
- mdakin 18y agoThat's true for one-liners in any language.
- FalconNL 18y agoNot necessarily. In Haskell the oneliners are frequently short enough to fit on one screen. 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)
- lincolnq 18y agoI've found that I really don't like this, aesthetically (mixing nesting styles in code looks bad) 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.
- nuclear_eclipse 18y ago> In python, it's hard to fuck it up: after a colon, you always newline and indent. But what about: if True: print "Yep" ;)
- whatusername 18y agoGet with the program: if True: print("Yep")
- ljlolel 18y agoDon't do that: http://www.python.org/dev/peps/pep-0008/ http://www.python.org/dev/peps/pep-0008/ Some features of Python are only really meant to be used at interactive prompts, like import STAR ( I can't write star?)
- nuclear_eclipse 18y agoCompletely agreed; I was just pointing it out.