Re: Use of whitespace
Aaron Optimizer Digulla <[email protected]> Tue, 5 Aug 2003 23:56:09 +0200
| Newsgroups | gmane.comp.programming.pragmatic |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Aug 05, 2003 at 09:27:16PM -0000, Eric Merritt wrote:
> I tend to be like using significant whitespace as long as I can use delimiters where
> I need to. What is your general opinion on the use of significant whitespace in a
> langauge.
>
> Two langauges that take somewhat different approches to this are haskell and
> python.
>
> haskell takes a layout based approach, basically everything at the same level of
> indentation is in the same block. I believe it also allows only spaces. It also allows
> for standard dilimiters where needed.
>
> Python uses indentation as well, though it allows both spaces and tabs to serve.
The first time I stubled over a language which used formatting was FORTRAN
and I hated it.
But when I saw Python, I realized that the formatted approach has its merits
and today, I can't think of a better way to structure code.
Pros:
1. It makes all code more readable. You just won't find badly formatted
code because that code wouldn't work.
2. You indent anyway, so why not use it to our advantage? Java/C wastes
a lot of screen space with the {} and even after all those years,
you still find "if() {" and "if()\n{".
3. The code tends to be less complicated too. When you have this:
for ...
if ...
if ...
if ...
if ...
a = 1
then you start to wonder at which level "a = 1" is. Usually, I simplify
the code then to make it more readable.
Cons:
1. People dislike formatted languages no matter how many advantages
they have.
2. Tabs and Spaces are still a problem with many *users* of editors. All
editors can handle them in such a way that Python can determine the
correct (ie. wanted) indentation but people complain "why can't I set
tabwidth to 3?". Tabs must stop at a multiple of 8 spaces or things
start to break apart when you start mixing them.
*Maybe* it is really time to leave the ASCII domain and start using
a real wordprocessor for the IDE. There are many WYSIWYG text components
out there and imagine to have formatted comments in your code!
Or the file format for the source files could be XML (which means they
can be (pre-)processed by a lot of tools and the syntax will be easily
extensible when we don't use a DTD ;-). Then, the IDE could display
that in a lot of ways.
--
==============================================
Sowatec AG, CH-8330 Pfäffikon (ZH)
Witzbergstr. 7, http://www.sowatec.com
Tel: +41-(0)1-952 55 55
Fax: +41-(0)1-952 55 66
----------------------------------------------
Aaron "Optimizer" Digulla, [email protected]
==============================================
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/sO0ANB/LIdGAA/ySSFAA/W4wwlB/TM
---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to:
pragmatic_lang-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/