RE: [Haskell] Re: Use of tab characters in indentation-sensitive code
{-# OPTIONS -tabsize 4 #-} I think it's still a bit of a hack, but at least the author tells you what their tabsize was when they wrote it, so you can recover their layout. You could always pre-process the source yourself with sed, if the compiler doesn't understand the option. -Original Message- From: Ronan Klyne [mailto:[EMAIL PROTECTED] Sent: 26 January 2004 03:53 To: The Haskell Mailing List Subject: [Haskell] Re: Use of tab characters in indentation-sensitive code 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 * Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. * This email has been scanned for all viruses by the MessageLabs Email Security System. For more information on a proactive email security service working around the clock, around the globe, visit http://www.messagelabs.com ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: Use of tab characters in indentation-sensitive code
Graham Klyne wrote (according to Wolfgang Thaller, snipped): I think that compilers should issue a warning when indentation that determines the scope of a construct is found to contain tab characters. In an ideal world, TAB characters would never have been put into ASCII, and this would be my preferred solution. However, since there would be some people who would object to such purity, a better alternative might be (a) to allow m TABs followed by n spaces at the start of lines. (b) to denote the indention of the line by the two numbers (m,n). (c) to give an error message when comparing two indentions (m1,n1),(m2,n2) where neither m1=m2,n1=n2, nor m1=m2,n1=n2. Incidentally Unicode allows far more possibilities for fun with indentation (for example half-spaces, IIRC). ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: Use of tab characters in indentation-sensitive code
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 ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Re: Use of tab characters in indentation-sensitive code
George Russell wrote: Graham Klyne wrote (according to Wolfgang Thaller, snipped): I think that compilers should issue a warning when indentation that determines the scope of a construct is found to contain tab characters. In an ideal world, TAB characters would never have been put into ASCII, and this would be my preferred solution. However, since there would be some people who would object to such purity, a better alternative might be (a) to allow m TABs followed by n spaces at the start of lines. (b) to denote the indention of the line by the two numbers (m,n). (c) to give an error message when comparing two indentions (m1,n1),(m2,n2) where neither m1=m2,n1=n2, nor m1=m2,n1=n2. Incidentally Unicode allows far more possibilities for fun with indentation (for example half-spaces, IIRC). The most flexible but safe solution is to simply define the indentation as the sequence of indentation characters used. Two consecutive lines are indented consistently whenever one indentation is a prefix of the other. Hence you may freely mix different indentation characters, but you must be consistent across lines. Any decent editor should be able to ensure that. With this solution, tab width is irrelevant and indentation may include whatever Unicode has. - Andreas -- Andreas Rossberg, [EMAIL PROTECTED] Computer games don't affect kids; I mean if Pac Man affected us as kids, we would all be running around in darkened rooms, munching magic pills, and listening to repetitive electronic music. - Kristian Wilson, Nintendo Inc. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: [Haskell] Re: Use of tab characters in indentation-sensitive code
Bayley, Alistair wrote: {-# OPTIONS -tabsize 4 #-} I think it's still a bit of a hack, but at least the author tells you what their tabsize was when they wrote it, so you can recover their layout. You could always pre-process the source yourself with sed, if the compiler doesn't understand the option. Using pr -T -e4 is less work than writing a sed script (you can't just replace each tab with 4 spaces; you need to use between 1 and 4 spaces depending upon the column in which the tab character occurs). -- Glynn Clements [EMAIL PROTECTED] ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Re: Use of tab characters in indentation-sensitive code
Am Sonntag, 25. Januar 2004 23:42 schrieb Sebastian Sylvan: Sean L. Palmer wrote: Besides, the idea would be not to use nbsp, 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 ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: [Haskell] Re: Use of tab characters in indentation-sensitive code
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). The Revised Haskell 98 Report contains this paragraph (sec. 9.3): For the purposes of the layout rule, Unicode characters in a source program are considered to be of the same, fixed, width as an ASCII character. However, to avoid visual confusion, programmers should avoid writing programs in which the meaning of implicit layout depends on the width of non-space characters. As for the width of the tab character: tab stops are every 8 columns. Period. The Haskell report says so :-P Cheers, Simon ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Re: Use of tab characters in indentation-sensitive code
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. :( (Sorry, but how did ascii get in there? Was the argument for Unicode or HTML?) As for mindset, the programming community was one of the first to try structure editors and other tools that gave a more abstract view of source code. The programming community has also been pretty quick to start using HTML and XML. That plain-text syntaxes for source code have survived suggests that there are good reasons for that and that the answer to the question in an earlier message Don't we have similar needs as other electronic document manipulators? is no, not similar enough. I work with HTML and XML all the time, and I have never felt any desire to represent programs that way; and when I do have to deal with an XML syntax for anything like a program (such as ant acripts, xslt stylesheets), I find it very unpleasant. -- Jeff ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] Re: [Haskell] Re: Use of tab characters in indentation-sensitive code
[Switching to Haskell-cafe] At 11:38 26/01/04 +0100, Andreas Rossberg wrote: The most flexible but safe solution is to simply define the indentation as the sequence of indentation characters used. Two consecutive lines are indented consistently whenever one indentation is a prefix of the other. Hence you may freely mix different indentation characters, but you must be consistent across lines. Any decent editor should be able to ensure that. With this solution, tab width is irrelevant and indentation may include whatever Unicode has. Neat. But unfortunately I don't think this, or any of the alternatives suggested, actually addresses the problem I have encountered, namely when an editing environment set up to handle local editing preferences is presented with code imported from another environment using different conventions. Conversion of all tabs to spaces (which I do to avoid this kind of problem when exporting my code to other environments) can cause correct code to become incorrect. There is, of course, a reasonable argument that my editing environment is at fault. #g Graham Klyne For email: http://www.ninebynine.org/#Contact ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] Re: Use of tab characters in indentation-sensitive code
Sean L. Palmer [EMAIL PROTECTED] 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 nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;Zot x - ... nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;Pleb - ... (Sorry, I couldn't help myself :-) -kzm -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: Use of tab characters in indentation-sensitive code
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 nbsp, but rather some indent paragraph tag. Sean - Original Message - From: Ketil Malde [EMAIL PROTECTED] To: Sean L. Palmer [EMAIL PROTECTED] Cc: Wolfgang Thaller [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Sunday, January 25, 2004 1:06 PM Subject: Re: Use of tab characters in indentation-sensitive code Sean L. Palmer [EMAIL PROTECTED] 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 nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;Zot x - ... nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;Pleb - ... (Sorry, I couldn't help myself :-) -kzm ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Re: Use of tab characters in indentation-sensitive code
Sean L. Palmer wrote: Besides, the idea would be not to use nbsp, 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 ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: Use of tab characters in indentation-sensitive code
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 ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: [Haskell] Re: Use of tab characters in indentation-sensitive code
Sebastian wrote: Sean L. Palmer wrote: Besides, the idea would be not to use nbsp, 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 ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: [Haskell] Re: Use of tab characters in indentation-sensitive code
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 nbsp, 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 -gt; ... indent /Pleb -gt; ... /David ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: Use of tab characters in indentation-sensitive code
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 [EMAIL PROTECTED] 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 spacesx = 1 TAB---y = 1 -- warning let TAB---x = 1 -- OK TAB---y = 2 -- OK spacesz = 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 [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
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 spacesx = 1 TAB---y = 1 -- warning let TAB---x = 1 -- OK TAB---y = 2 -- OK spacesz = 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 [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
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 [EMAIL PROTECTED] To: [EMAIL PROTECTED] 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 spacesx = 1 TAB---y = 1 -- warning let TAB---x = 1 -- OK TAB---y = 2 -- OK spacesz = 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 [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: Use of tab characters in indentation-sensitive code
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sean L. Palmer Sent: Saturday, January 24, 2004 9:21 PM To: Wolfgang Thaller; [EMAIL PROTECTED] 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 [EMAIL PROTECTED] To: [EMAIL PROTECTED] 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 spacesx = 1 TAB---y = 1 -- warning let TAB---x = 1 -- OK TAB---y = 2 -- OK spacesz = 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 [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Use of tab characters in indentation-sensitive code
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 * [EMAIL PROTECTED] * Often in error, never in doubt The absurd is the essential concept and the first truth.--Camus http://www.cs.berkeley.edu/~krc/ ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Use of tab characters in indentation-sensitive code
I have found on a number of occasions that the use of tab characters in indentation-sensitive code is a cause of compilation errors, on occasions where I have opened the file with an editor which ap0plies a convention other than 8 spaces for a tab. I fear that sooner or later, one of these errors is going to manifest as a logic error. I would suggest that, where code uses the indentation-scope feature of Haskell, it would reduce the possibility for errors of all tabs were replaced with a corresponding number of spaces. I think that compilers should issue a warning when indentation that determines the scope of a construct is found to contain tab characters. #g Graham Klyne For email: http://www.ninebynine.org/#Contact ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Use of tab characters in indentation-sensitive code
Graham Klyne writes: I think that compilers should issue a warning when indentation that determines the scope of a construct is found to contain tab characters. I second that. In the same spirit, the compiler should issue a warning when tab is used in literal strings, rather than \t, because some editors _do_ mess up the formatting and thus change the program! IMHO, tab is a character you'd really want to avoid using in source code at all, but obviously, there are others who think otherwise. ;-) Peter ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell