January 25, 2011 [phobos] [dmd-internals] svn-->git migration | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Jan 25, 2011, at 10:59 AM, Walter Bright wrote:
>
> It obviously goes back at least as far as ASCII itself. LF means "line feed", which advances the platen one line. CR means "carriage return" which moves the print head to the beginning of the line. These are separate operations, and a lot of older programs relied on it. ASCII terminals (and teletypes) all operated this way.
Most (all?) internet protocols require CRLF for line termination as well.
|
January 25, 2011 [phobos] [dmd-internals] svn-->git migration | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | On Tuesday 25 January 2011 21:53:18 Sean Kelly wrote:
> On Jan 25, 2011, at 10:59 AM, Walter Bright wrote:
> > It obviously goes back at least as far as ASCII itself. LF means "line feed", which advances the platen one line. CR means "carriage return" which moves the print head to the beginning of the line. These are separate operations, and a lot of older programs relied on it. ASCII terminals (and teletypes) all operated this way.
>
> Most (all?) internet protocols require CRLF for line termination as well.
Considering what \n and \r\n are typically used for, \r\n is technically the most correct, because you're both going to the next line and going to the beginning of the line. However, given that you really never need to just go to the beginning of the line or the same place on the next - or if you do, you need something a lot more powerful (like ncurses) - it's rather silly to use two characters for it. So, using \n makes good sense.
The problem, of course, is that there's plenty of legacy stuff that uses \r\n, and so it would take a while to go away, even if everything switched to it. But for whatever reason, Windows has never followed the rest of the world and switched to \n (possibly because they prize backwards compatability so much, or possibly because they just plain don't care what the rest of the computing world is up to), so we're still stuck with both. Really, I think that everything should use \n at this point, but until Windows starts to, we're pretty much stuck. And like any compatability problem between systems, it causes problems between systems.
At least the Mac now uses \n instead of \r. Otherwise, there would be _three_ ways to end a line that we'd have to deal with.
- Jonathan M Davis
|
January 26, 2011 [phobos] [dmd-internals] svn-->git migration | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Jan 25, 2011, at 10:20 PM, Jonathan M Davis wrote: > On Tuesday 25 January 2011 21:53:18 Sean Kelly wrote: >> On Jan 25, 2011, at 10:59 AM, Walter Bright wrote: >>> It obviously goes back at least as far as ASCII itself. LF means "line feed", which advances the platen one line. CR means "carriage return" which moves the print head to the beginning of the line. These are separate operations, and a lot of older programs relied on it. ASCII terminals (and teletypes) all operated this way. >> >> Most (all?) internet protocols require CRLF for line termination as well. > > Considering what \n and \r\n are typically used for, \r\n is technically the most correct, because you're both going to the next line and going to the beginning of the line. However, given that you really never need to just go to the beginning of the line or the same place on the next - or if you do, you need something a lot more powerful (like ncurses) - it's rather silly to use two characters for it. So, using \n makes good sense. Terminals needed the distinction, but few are in use any more. Probably in military use and in the back office of some large corporations. > The problem, of course, is that there's plenty of legacy stuff that uses \r\n, and so it would take a while to go away, even if everything switched to it. But for whatever reason, Windows has never followed the rest of the world and switched to \n (possibly because they prize backwards compatability so much, or possibly because they just plain don't care what the rest of the computing world is up to), so we're still stuck with both. Really, I think that everything should use \n at this point, but until Windows starts to, we're pretty much stuck. And like any compatability problem between systems, it causes problems between systems. That would be nice, but unlikely :-) |
January 26, 2011 [phobos] [dmd-internals] svn-->git migration | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly |
Sean Kelly wrote:
>
>
> Terminals needed the distinction, but few are in use any more. Probably in military use and in the back office of some large corporations.
>
>
>
Many embedded systems communicate via a serial port.
|
January 26, 2011 [phobos] The time has come to destroy all y'all over CR/LF | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | CR/LF sucks. There is no negotiation. What are my credentials? I went to highschool in the late 80s but that was Communist Romania, which turns the clock back by at least 15 years so my expertise dates from the early 70s. My highschool was specializing in IT, and I actually _worked_ on VT 100, which was a treat compared to the punch card punchers that I'd started on. So: indeed CR or '\r' means the carriage goes back to the beginning of the line without changing the line. LF or '\n' means the paper feed (those infinite papers with holes on the margins) goes forward one step. On occasion you'd need CR without LF. The classic example is that you'd print the line twice to simulate poor man's bold. Other tricks people played were to simulate diacritics by overprinting e.g. 't' and ','. On non-paper terminals, CR is great for quickly updating a line of information without scrolling down. It's simpler than using curses and effective. But the fact of the matter is that you almost NEVER needed LF alone. When you want the paper to scroll, you usually do so because you want to print some more stuff starting the next line, not in the arbitrary point that continues after the last character on the current line! You could play games with LF followed by a number of backspaces but I never saw anyone doing so. The only one place I've seen LF actually ever used was in ASCII art and landscape ACII graphing programs, and even then it was rare and an optimization that was insignificant in the grand scheme of things. So CR alone should be available as "go to the beginning of the current line". LF alone should mean "go to the beginning of the next line". And that should be it. Unix got this right. CP/M et al got this wrong. Andrei |
January 26, 2011 [phobos] The time has come to destroy all y'all over CR/LF | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | What I find interesting was that Apple went with \r and that \n\r is different from \r\n and also why Linux applications, such as Vim don't actually interpret \r as a carnage return so that, if nothing else, you don't have to see ^M at the end of the line.
On Wed, Jan 26, 2011 at 10:36 AM, Andrei Alexandrescu <andrei at erdani.com> wrote:
> CR/LF sucks. There is no negotiation.
|
January 26, 2011 [phobos] The time has come to destroy all y'all over CR/LF | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu |
Andrei Alexandrescu wrote:
>
> So CR alone should be available as "go to the beginning of the current line". LF alone should mean "go to the beginning of the next line". And that should be it. Unix got this right. CP/M et al got this wrong.
>
CP/M did not invent that meaning for LF. LF goes back decades earlier than CP/M.
In the early 80's, unix wasn't seen much. The best systems were the DEC computers, and a lot of software professionals expected DEC to become the dominant player. DEC operating systems were widely seen as the best. (IBM was still mired in their ridiculous EBCDIC encoding.)
I suspect that unix and its conventions would be dead by now if not for Linux.
|
January 26, 2011 [phobos] The time has come to destroy all y'all over CR/LF | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Forgive my ignorance, but why is this such a big issue? Shouldn't any decent programmer tool (diff utility, editor, IDE, etc.) be able to interpret CR, LF and CR LF as effectively meaning the same thing and do what you mean? In the context of source code noone ever wants to go to the beginning of the current line. The only time it can become ambiguous is when a CR LF was actually produced by two different edits with different settings (and is therefore supposed to mean two newlines, not one) and even then it only mildly screws up the whitespace. Bottom line: I fail to see why different line endings should be such an issue in the first place, unless we're using some overly strict or Stone Age tool that favors absolute adherence to some specification over common sense. In such cases it's more the tool that's the problem, not the source file. I don't give a hoot which line ending anyone uses, because all my tools seem to "just work" regardless, and I have absolutely no clue what line ending my IDE is set up to use because I don't understand why it really matters in practice. On Wed, Jan 26, 2011 at 2:18 PM, Walter Bright <walter at digitalmars.com>wrote: > > > Andrei Alexandrescu wrote: > >> >> So CR alone should be available as "go to the beginning of the current line". LF alone should mean "go to the beginning of the next line". And that should be it. Unix got this right. CP/M et al got this wrong. >> >> > CP/M did not invent that meaning for LF. LF goes back decades earlier than CP/M. > > In the early 80's, unix wasn't seen much. The best systems were the DEC computers, and a lot of software professionals expected DEC to become the dominant player. DEC operating systems were widely seen as the best. (IBM was still mired in their ridiculous EBCDIC encoding.) > > I suspect that unix and its conventions would be dead by now if not for Linux. > > _______________________________________________ > phobos mailing list > phobos at puremagic.com > http://lists.puremagic.com/mailman/listinfo/phobos > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20110126/cc3b7eee/attachment-0001.html> |
January 26, 2011 [phobos] The time has come to destroy all y'all over CR/LF | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 1/26/11 1:18 PM, Walter Bright wrote: > > > Andrei Alexandrescu wrote: >> >> So CR alone should be available as "go to the beginning of the current line". LF alone should mean "go to the beginning of the next line". And that should be it. Unix got this right. CP/M et al got this wrong. >> > > CP/M did not invent that meaning for LF. LF goes back decades earlier than CP/M. I mentioned CP/M because it's the first OS that inherited the sequence without actually being backed up by a paper-based TTY, where a very weak argument could be constructed that CR/LF is how the mechanics of the system works. > In the early 80's, unix wasn't seen much. The best systems were the DEC computers, and a lot of software professionals expected DEC to become the dominant player. DEC operating systems were widely seen as the best. (IBM was still mired in their ridiculous EBCDIC encoding.) > > I suspect that unix and its conventions would be dead by now if not for Linux. Be that as it may, in Unix '\n' means "go to the beginning of next line" and '\r' means "go to the beginning of the current line". I argued destructively that this is the way things should have been EVEN on paper-based terminals and NO DISCUSSION the way things should be on today's terminal emulators. Unix got this right. CP/M et al got this wrong. Andrei |
January 26, 2011 [phobos] The time has come to destroy all y'all over CR/LF | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | On 26 January 2011 20:37, David Simcha <dsimcha at gmail.com> wrote:
> Forgive my ignorance, but why is this such a big issue?? Shouldn't any decent programmer tool (diff utility, editor, IDE, etc.) be able to interpret CR, LF and CR LF as effectively meaning the same thing and do what you mean?
The thing Microsoft should be shot for, is for continuing to provide a default text editor (Notepad) which can't handle LF as an end-of-line marker. That's inexcusable.
How many end-of-lines are in "\n\r\n\n\r" ? Notepad says 1.
|
Copyright © 1999-2021 by the D Language Foundation