Project

General

Profile

Feature #888

Escaped newline to allow a long line to be split into several "physical lines"

Added by John Abbott almost 8 years ago. Updated almost 8 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
enhancing/improving
Target version:
Start date:
06 Jun 2016
Due date:
% Done:

0%

Estimated time:
Spent time:

Description

Some languages allow long lines to be split into several "physical lines" by inserting an escaped-newline which is simply regarded as no character at all.

An example is in a makefile where a line ending with backslash is adjoined to the following line (and the backslash and newline are elided).

Should we add such a feature to CoCoA-5?

History

#1 Updated by John Abbott almost 8 years ago

I was surprised not to find this issue already in redmine; I'm sure we have talked about it (in the distant past... perhaps before we started to use redmine?).

The idea is to allow something like:

A := 123\
456;

which would be the same as
A := 123456;

because the backslash-newline digraph is simply "ignored" by the parser (apart from incrementing the line counter). In principle, backslash-newline could even appear inside a keyword!

Such a facility would make it very easy to split a long "logical" line across many short "physical lines": just insert backslash-newline every 75 characters.

#2 Updated by John Abbott almost 8 years ago

I have just checked what happens with bash (which also uses the backslash-newline convention): it may appear inside a keyword or a variable name; however an end-of-line comment (i.e. preceded by a hash) which ends with a backslash does not then extend to the next line.

If we do adopt this idea, what should happen if an end-of-line comment meets a backslash-newline digraph? Which behaviour is more "natural" (or less "unnatural")?

Note that, as in the example above, even an integer literal can be split across several lines; this could be occasionally useful.

#3 Updated by John Abbott almost 8 years ago

Unfortunately there are probably some places where backslash-newline cannot be blindly inserted without changing the interpretation of the line: for instance, it might be "delicate" putting one inside another escape sequence... (or inside the backslash-newline escape sequence!)

What should the effect of backslash-backslash-newline-newline be? Probably backslash-backslash is an escape sequence for a single backslash character.

Of course, the most likely use case is splitting a very long line which has been produced as output of some program, and this will probably not contain escape sequences... in such instances there should be no problem inserting backslash-newline blindly whereever is convenient.

Also available in: Atom PDF