Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #148137
| Subject | Re: curiosity about compiler phases |
|---|---|
| Newsgroups | comp.lang.c |
| References | <9585199f-546a-46f8-ac2a-de27cc08a3f5@googlegroups.com> <FcZBF.211$rX6.122@fx22.am4> <PXZBF.74624$hh5.43882@fx07.iad> <dK_BF.12$LP4.8@fx40.am4> <87imnb5poj.fsf@bsb.me.uk> |
| From | Bart <bc@freeuk.com> |
| Message-ID | <_u9CF.666$LP4.521@fx40.am4> (permalink) |
| Organization | virginmedia.com |
| Date | 2019-11-23 12:21 +0000 |
On 23/11/2019 01:47, Ben Bacarisse wrote:
> Bart <bc@freeuk.com> writes:
>
>> Where a language has line continuation to split source across multiple
>> lines, then it is highly unusual to allow that split in the middle of
>> a token.
>
> It's a comparatively rare feature altogether, but I don't think the
> balance between the two ways of doing it it quite as dramatic as you
> suggest. In C, C++ and Fortran, line continuations are simply literal
> line pasting,
I couldn't get that behaviour using the & line-continuation of modern
Fortran; I couldn't use it to split a keyword.
but what languages don't do it that way? I think Python
> and Visual Basic are two, but are there lots more?
Python uses \ that can't split names. Ruby is another, according to my
brief test.
> In my view, if you are going to do it, doing it simply and entirely
> literally makes it both easy to document and the more broadly useful.
It creates complications. You are forced to either have a separate pass
just to combine lines (ie. replace \crlf or \lf sequences with nothing,
meaning copying lots text).
Or having to deal with \crlf and \lf in the middle of every kind of
token. And not just that, but also \whitespace or \anything else.
My tidy loop for scanning the remainder of a C identifier (here
expressed as untested C):
while (alphamap[c = *lxsptr++] } hsum = (hsum<<4) + c;
is no longer going to be that tidy. Or you have to use other approaches
such as a getnextchar() function (which now relies on inlining to keep
it efficient).
It creates difficulties for tools such as those three editors I
mentioned that couldn't properly highlight such split keywords.
It also causes that problem with // comments:
// try c:\texts\
fopen(file);
where the following line is silently commented out (although editors
seem to be wise to that one).
And this example:
printf("Hello\\
nWorld!");
is not handled properly by tcc (others, apart from bcc, are OK).
(I would have expected this feature to go in hand with allowing /*...*/
comments in the middle of a token, but that's not allowed.)
>> What is the purpose
>
> It was useful whenever C was used in line-length limited contexts. I've
> seen it used when transmitting C over some early messaging systems, and
> I imagine it was (any maybe still is) useful where file systems impose
> fixed-length records. The line breaking and reconstruction can be done
> without any knowledge of tokens.
Actually I would find that useful for MSVC which has problems with my
long string constants, if I could literally split them anywhere
including in the middle of an escape sequence like the example above.
But I couldn't do that (even if I'd known about it) because it seems
like such a naff way of dealing with that problem. Also because it
wouldn't work with tcc and bcc.
Primarily though because I feel the solution here is NOT to have some
silly arbitrary limit on string lengths - fix the compiler not the program.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
curiosity about compiler phases Thiago Adams <thiago.adams@gmail.com> - 2019-11-07 05:28 -0800
Re: curiosity about compiler phases Nick Bowler <nbowler@draconx.ca> - 2019-11-22 19:25 +0000
Re: curiosity about compiler phases "A. K." <minforth@arcor.de> - 2019-11-22 12:19 -0800
Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-22 22:22 +0000
Typo? (Was: curiosity about compiler phases) gazelle@shell.xmission.com (Kenny McCormack) - 2019-11-22 22:34 +0000
Re: Typo? (Was: curiosity about compiler phases) Bart <bc@freeuk.com> - 2019-11-22 23:49 +0000
Re: Typo? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2019-11-22 19:26 -0700
Re: curiosity about compiler phases scott@slp53.sl.home (Scott Lurndal) - 2019-11-22 23:12 +0000
Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-23 00:06 +0000
Re: curiosity about compiler phases Richard Damon <Richard@Damon-Family.org> - 2019-11-22 20:34 -0500
Re: curiosity about compiler phases Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-23 01:47 +0000
Re: curiosity about compiler phases Richard Damon <Richard@Damon-Family.org> - 2019-11-22 21:21 -0500
Re: curiosity about compiler phases Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-24 03:26 +0000
Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-24 11:29 +0000
Re: curiosity about compiler phases Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-24 16:49 +0000
Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-23 12:21 +0000
Re: curiosity about compiler phases Richard Damon <Richard@Damon-Family.org> - 2019-11-23 10:08 -0500
Re: curiosity about compiler phases scott@slp53.sl.home (Scott Lurndal) - 2019-11-23 15:49 +0000
Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-23 16:21 +0000
Re: curiosity about compiler phases Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-24 03:37 +0000
Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-24 11:25 +0000
Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-25 14:06 +0000
Re: curiosity about compiler phases Keith Thompson <kst-u@mib.org> - 2019-11-22 21:25 -0800
Beyond our pay grade (Was: curiosity about compiler phases) gazelle@shell.xmission.com (Kenny McCormack) - 2019-11-23 07:43 +0000
Re: curiosity about compiler phases Thiago Adams <thiago.adams@gmail.com> - 2019-11-23 06:28 -0800
Re: curiosity about compiler phases Thiago Adams <thiago.adams@gmail.com> - 2019-11-23 06:39 -0800
Re: curiosity about compiler phases Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2019-11-23 09:46 -0500
Re: curiosity about compiler phases Richard Damon <Richard@Damon-Family.org> - 2019-11-23 10:16 -0500
Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-23 16:13 +0000
Re: curiosity about compiler phases Thiago Adams <thiago.adams@gmail.com> - 2019-11-25 03:24 -0800
Re: curiosity about compiler phases Bonita Montero <Bonita.Montero@gmail.com> - 2019-11-23 08:43 +0100
csiph-web