Re: Use of tab characters in indentation-sensitive code
Graham Klyne wrote:
I think that compilers should issue a warning when indentation that determines the scope of a construct is found to contain tab characters.
I'd say, when it "is found to contain a mixture of tab and space characters". I have successfully written a lot of Haskell code that uses tabs *exclusively* - in that case, the meaning of the program *doesn't* depend on how the tab characters are interpreted. IMHO, there should only be warnings about tabs when their size makes a difference to the meaning of the program, as shown in the examples below: let <spaces>x = 1 <TAB--->y = 1 -- warning let <TAB--->x = 1 -- OK <TAB--->y = 2 -- OK <spaces>z = 3 -- warning a = let x = 1 y = 2 -- OK in ... b = let x = 1 <TAB--->y = 2 -- warning in ... There are many editors that automatically mix tabs and spaces in indentation (and I don't like that - what's it good for?), but some people will certainly want to continue to use them, so I'm not sure if adding warnings like these would be acceptable to them. Cheers, Wolfgang
Why has HTML been out for many many years, and yet programming languages still use plain ASCII text exclusively? Don't we have similar needs as other electronic document manipulators? Someone should decide on a subset of HTML that is intended for programming. Then we could use *actual* indentation instead of tabs or spaces. It could also unify or abstract away commenting style, moving it from the domain of the language (lexer) to the domain of the layout protocol. But if I stop the wishful thinking, Wolfgang is right. Tabs are ok so long as they are used exclusively. In fact, if the tab size equals the indent size, it makes it quite easy to *change* the indent size when the source is worked on by various people with different indent preferences. Sean ----- Original Message ----- From: "Wolfgang Thaller" <wolfgang.thaller@gmx.net> To: <haskell@haskell.org> Sent: Saturday, January 24, 2004 9:29 AM Subject: Re: Use of tab characters in indentation-sensitive code
Graham Klyne wrote:
I think that compilers should issue a warning when indentation that determines the scope of a construct is found to contain tab characters.
I'd say, when it "is found to contain a mixture of tab and space characters". I have successfully written a lot of Haskell code that uses tabs *exclusively* - in that case, the meaning of the program *doesn't* depend on how the tab characters are interpreted. IMHO, there should only be warnings about tabs when their size makes a difference to the meaning of the program, as shown in the examples below:
let <spaces>x = 1 <TAB--->y = 1 -- warning
let <TAB--->x = 1 -- OK <TAB--->y = 2 -- OK <spaces>z = 3 -- warning
a = let x = 1 y = 2 -- OK in ...
b = let x = 1 <TAB--->y = 2 -- warning in ...
There are many editors that automatically mix tabs and spaces in indentation (and I don't like that - what's it good for?), but some people will certainly want to continue to use them, so I'm not sure if adding warnings like these would be acceptable to them.
Cheers,
Wolfgang
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Sean,
Why has HTML been out for many many years, and yet programming languages still use plain ASCII text exclusively? Don't we have similar needs as other electronic document manipulators?
Mmm ... I don't like that idea too much. And that's for a rather obvious reason actually: writing HTML/XML means *lots of typing*. If I had to choose between a language that relies on identation and one that relies on explicit markup tags, I guess I'd pick the former since a less verbose language allows for higher productivity and more readability. However, IMHO a language that does not rely on any markup (line breaks, indentation) at all is even more preferrable. Regards, Stefan
-----Original Message----- From: haskell-bounces@haskell.org [mailto:haskell-bounces@haskell.org] On Behalf Of Sean L. Palmer Sent: Saturday, January 24, 2004 9:21 PM To: Wolfgang Thaller; haskell@haskell.org Subject: Re: Use of tab characters in indentation-sensitive code
Why has HTML been out for many many years, and yet programming languages still use plain ASCII text exclusively? Don't we have similar needs as other electronic document manipulators?
Someone should decide on a subset of HTML that is intended for programming. Then we could use *actual* indentation instead of tabs or spaces. It could also unify or abstract away commenting style, moving it from the domain of the language (lexer) to the domain of the layout protocol.
But if I stop the wishful thinking, Wolfgang is right. Tabs are ok so long as they are used exclusively. In fact, if the tab size equals the indent size, it makes it quite easy to *change* the indent size when the source is worked on by various people with different indent preferences.
Sean
----- Original Message ----- From: "Wolfgang Thaller" <wolfgang.thaller@gmx.net> To: <haskell@haskell.org> Sent: Saturday, January 24, 2004 9:29 AM Subject: Re: Use of tab characters in indentation-sensitive code
Graham Klyne wrote:
I think that compilers should issue a warning when indentation that determines the scope of a construct is found to contain tab characters.
I'd say, when it "is found to contain a mixture of tab and space characters". I have successfully written a lot of Haskell code that uses tabs *exclusively* - in that case, the meaning of the program *doesn't* depend on how the tab characters are interpreted. IMHO, there should only be warnings about tabs when their size makes a difference to the meaning of the program, as shown in the examples below:
let <spaces>x = 1 <TAB--->y = 1 -- warning
let <TAB--->x = 1 -- OK <TAB--->y = 2 -- OK <spaces>z = 3 -- warning
a = let x = 1 y = 2 -- OK in ...
b = let x = 1 <TAB--->y = 2 -- warning in ...
There are many editors that automatically mix tabs and spaces in indentation (and I don't like that - what's it good for?), but some people will certainly want to continue to use them, so I'm not sure if adding warnings like these would be acceptable to them.
Cheers,
Wolfgang
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
On Sat, Jan 24, 2004 at 12:21:03PM -0800, Sean L. Palmer wrote:
Why has HTML been out for many many years, and yet programming languages still use plain ASCII text exclusively? Don't we have similar needs as other electronic document manipulators?
Because HTML was designed as a language for constructing hypertext documents. It's (moderately) good at that. It would be terrible for constructing programs (if you're not convinced, try reading HTML e-mail in a text-based mail reader sometime). This is not to say that we *shouldn't* take advantage of technology going beyond ASCII text for expressing programs, just that HTML would be entirely the wrong technology. -- Kirsten Chevalier * krc@cs.berkeley.edu * Often in error, never in doubt "The absurd is the essential concept and the first truth."--Camus http://www.cs.berkeley.edu/~krc/
"Sean L. Palmer" <seanpalmer@verizon.net> writes:
Why has HTML been out for many many years, and yet programming languages still use plain ASCII text exclusively? Don't we have similar needs as other electronic document manipulators?
So we could write: foo bar = case bar of Zot x -> ... Pleb -> ... (Sorry, I couldn't help myself :-) -kzm -- If I haven't seen further, it is by standing in the footprints of giants
Joking aside, surely you intelligent people realize that the internals of a file format have nothing whatsoever to do with the user interface of the editing tool. Something like this would be completely transparent *if* you used the right tools. This just shows how deeply ingrained the ascii plain text mindset is in the programming community. I don't expect anything like this to ever fly, for this reason. You guys won't let it. :( Besides, the idea would be not to use  , but rather some "indent paragraph" tag. Sean ----- Original Message ----- From: "Ketil Malde" <ketil+haskell@ii.uib.no> To: "Sean L. Palmer" <seanpalmer@verizon.net> Cc: "Wolfgang Thaller" <wolfgang.thaller@gmx.net>; <haskell@haskell.org> Sent: Sunday, January 25, 2004 1:06 PM Subject: Re: Use of tab characters in indentation-sensitive code
"Sean L. Palmer" <seanpalmer@verizon.net> writes:
Why has HTML been out for many many years, and yet programming languages still use plain ASCII text exclusively? Don't we have similar needs as other electronic document manipulators?
So we could write:
foo bar = case bar of Zot x -> ... Pleb -> ...
(Sorry, I couldn't help myself :-)
-kzm
Sean L. Palmer wrote:
Besides, the idea would be not to use  , but rather some "indent paragraph" tag.
This is kind-of a cool idea. If I ever take a course involving writing my own language I'll be sure to incorporate this idea. /S
Sebastian wrote:
Sean L. Palmer wrote:
Besides, the idea would be not to use  , but rather some "indent paragraph" tag.
This is kind-of a cool idea. If I ever take a course involving writing my own language I'll be sure to incorporate this idea.
This idea of an indent paragraph tag has been incorporated in various development environments and, partly, in languages. It is called the tab character. Environments such as Emacs can be trained to treat those tab characters as an indentation tag. And even in word processing this tagging character has been used quite extensively. :-| /David
Am Sonntag, 25. Januar 2004 23:42 schrieb Sebastian Sylvan:
Sean L. Palmer wrote:
Besides, the idea would be not to use  , but rather some "indent paragraph" tag.
This is kind-of a cool idea. If I ever take a course involving writing my own language I'll be sure to incorporate this idea.
It's not so cool, in my opinion. And indent paragraph tag would belong to visual formatting. If you start using tags, why wouldn't you use them to denote the logical structure of the program like the { ; } syntax does? Obviously, the approach of denoting structure via indentation was used for Haskell only because indenting is what most programmers use anyway when they have some kind of substructure. You don't need any extra markup, you just denote structure by using an obvious, nice-looking indentation style. If you would use indent paragraph tags and look at the source code, this source code wouldn't look very nice anymore. You could argue that you use a special editing tool. But then you could use the logical markup I talked about above and the editing tool would do the indentation on the basis of the structure.
/S
Wolfgang
--- "Sean L. Palmer" <seanpalmer@verizon.net> wrote:
Joking aside, surely you intelligent people realize that the internals of a file format have nothing whatsoever to do with the user interface of the editing tool. Something like this would be completely transparent *if* you used the right tools.
This just shows how deeply ingrained the ascii plain text mindset is in the programming community. I don't expect anything like this to ever fly, for this reason. You guys won't let it. :(
Mmmmm... The dark side clouds everything... Seriously, Plain Text (TM) is a proven technology for editing code, and leveraging the power of XML just to improve over indentation might be off-target. Seriously, programs can (or should...) be encoded at a level of abstraction that matches their semantics more closely than matrix of caracters, and you're right to raise the issue. Seriously, Haskell is already so powerful (read: enables the programmer to define it own astractions) that any layer above it is easily useless. Obviously, something can be done though; http://www.cs.kent.ac.uk/projects/refactor-fp/hare.html Just some thoughts... Cheers! JP. __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/
On Sun, 25 Jan 2004, Sean L. Palmer wrote:
Joking aside, surely you intelligent people realize that the internals of a file format have nothing whatsoever to do with the user interface of the editing tool. Something like this would be completely transparent *if* you used the right tools.
Wait a second. Aren't you the one who suggested HTML? HTML is a plain-text format. It's not a collection of editing tools on top of an opaque file format. Yes, HTML specifies certain sequences like <i> ... </i> to delimit nested subblocks. In Haskell source code, those sequences include { ... } and {- ... -}. If you want to think in terms of markup, Haskell already has it. There are GUI programmer's editors that understand source code formats the same way that GUI HTML editors understand HTML. They highlight keywords and comment blocks, let you jump to the definition point of any identifier, and so on. The source code they show you tends to look a lot like the underlying text format, but there's no inherent need for that; I just think that no one's found anything substantially better. I think a hierarchical folding editor for Haskell is a great idea. It would read source code with layout for compatibility, but the code it wrote would always have explicit { ; } tags. Those low-level tags wouldn't show up in the GUI, which would use a higher-level representation, perhaps something like Mathcad. I'm sure lots of people would use it. The problem, as always, is that someone has to hunker down and write the thing. Changing the markup syntax in the underlying text format won't help anything, and going to a binary format would be even worse. It's the tools that matter.
This just shows how deeply ingrained the ascii plain text mindset is in the programming community. I don't expect anything like this to ever fly, for this reason. You guys won't let it. :(
Are you absolutely 100% sure you aren't suffering from a "web mindset"? -- Ben
Sean wrote:
Joking aside, surely you intelligent people realize that the internals of a file format have nothing whatsoever to do with the user interface of the editing tool. Something like this would be completely transparent *if* you used the right tools.
But then you would be forced to use exactly those tools and/or that development platform. I have programmed in languages that extend beyond ASCII (most modern languages actually do, but that is another story.) One of these languages is APL or, more specifically, A+. Not a nice experience, and that is "just" an extension w.r.t. character table used. Once you leave the sheltered environment of a properly set up Emacs with proper fonts installed, it all looks like random junk.
This just shows how deeply ingrained the ascii plain text mindset is in the programming community. I don't expect anything like this to ever fly, for this reason. You guys won't let it. :(
We guys try and some of us have used non-alphanumeric symbols, but they do not add much, unless one leaves the linear realm of text completely and enters the world of diagrammatic notations.
Besides, the idea would be not to use  , but rather some "indent paragraph" tag.
That would hardly make it more tractable outside the sheltered "Tag Editor," would it? foo bar = case bar of <indent />Zot x -> ... <indent />Pleb -> ... /David
I support the idea that somthing should be done. I would like to suggest that the compiler references an environment variable to determine how many spaces a tab represents. I realise that this would cause the same code to run on some systems and fail on others, but it would allow a developer to set up a comfortable working system without tab characters ruining the logic of a program. # r On Sat, 24 Jan 2004 18:29:46 +0100, Wolfgang Thaller <wolfgang.thaller@gmx.net> wrote:
Graham Klyne wrote:
I think that compilers should issue a warning when indentation that determines the scope of a construct is found to contain tab characters.
I'd say, when it "is found to contain a mixture of tab and space characters". I have successfully written a lot of Haskell code that uses tabs *exclusively* - in that case, the meaning of the program *doesn't* depend on how the tab characters are interpreted. IMHO, there should only be warnings about tabs when their size makes a difference to the meaning of the program, as shown in the examples below:
let <spaces>x = 1 <TAB--->y = 1 -- warning
let <TAB--->x = 1 -- OK <TAB--->y = 2 -- OK <spaces>z = 3 -- warning
a = let x = 1 y = 2 -- OK in ...
b = let x = 1 <TAB--->y = 2 -- warning in ...
There are many editors that automatically mix tabs and spaces in indentation (and I don't like that - what's it good for?), but some people will certainly want to continue to use them, so I'm not sure if adding warnings like these would be acceptable to them.
Cheers,
Wolfgang
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Wolfgang Thaller writes (to the Haskell mailing list):
IMHO, there should only be warnings about tabs when their size makes a difference to the meaning of the program,
I agree and would suggest an even more stringent test to warn against
a = let x = 1 y = 2 -- OK in ...
because the (visual) interpretation depends on the font you use (fixed width vs. proportional). Cheers, Ronny Wichers Schreur
participants (12)
-
Ben Rudiak-Gould -
David Bergman -
JP Bernardy -
Ketil Malde -
Kirsten Chevalier -
Ronan Klyne -
Ronny Wichers Schreur -
Sean L. Palmer -
Sebastian Sylvan -
Stefan Holdermans -
Wolfgang Jeltsch -
Wolfgang Thaller