About the difficulty to use sensible line breaks in expressions,
without adding syntactically spurious escape characters.
(Note 1: The need for line breaks arise with longer expressions.)
(Note 2: Yes, we can use/add line-continuation/escape characters.)
1
2 function f (a,b) { }
3
4 {
5 # okay
6 if (f(a,b) < c + d) print a, b, c, d
7
8 # okay
9 if (f(a,b) < c + d) print a, b,
10 c, d
11
12 # okay
13 if (f(a,
14 b) < c + d) print a, b, c, d
15
16 # error
17 if (f(a, b) <
18 c + d) print a, b, c, d
19
20 # error
21 if (f(a,b) < c +
22 d) print a, b, c, d
23
24 # error
25 if (f(a,b) < c + d
26 ) print a, b, c, d
27
28 # okay
29 if (f(a,b) < c &&
30 d) print a, b, c, d
31
32 # okay
33 if (f(a,b) < (c &&
34 d)) print a, b, c, d
35
36 # error
37 if (f(a,b) < (c +
38 d)) print a, b, c, d
39 }
awk: awk-breaks:18: if (f(a, b) <
awk: awk-breaks:18: ^ unexpected newline or end of string
awk: awk-breaks:18: c + d) print a, b, c, d
awk: awk-breaks:18: ^ syntax error
awk: awk-breaks:22: if (f(a,b) < c +
awk: awk-breaks:22: ^ unexpected newline or end of string awk: awk-breaks:26: if (f(a,b) < c + d
awk: awk-breaks:26: ^ unexpected newline or end of
string
awk: awk-breaks:38: if (f(a,b) < (c +
awk: awk-breaks:38: ^ unexpected newline or end of string awk: awk-breaks:38: d)) print a, b, c, d
awk: awk-breaks:38: ^ syntax error
awk: awk-breaks:38: d)) print a, b, c, d
awk: awk-breaks:38: ^ syntax error
awk: awk-breaks:39: d)) print a, b, c, d
awk: awk-breaks:39: ^ unexpected
newline or end of string
Is throwing (some/any of) these syntax errors mandated by POSIX? - If
not, Awk variants, I suppose, could decide to implement semantically
sensible [valid] interpretations and remove existing inconsistencies?
I have a fork of gawk called egawk (enhanced gnu awk) where this
approach could be tried.
So before trying to upstreaming, you need a convincing argument why standard-conforming backslash-newline continuations aren't good enough.
...About the difficulty to use sensible line breaks in expressions,
without adding syntactically spurious escape characters.
(Note 2: Yes, we can use/add line-continuation/escape characters.)
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 793 |
Nodes: | 10 (1 / 9) |
Uptime: | 38:08:17 |
Calls: | 11,106 |
Calls today: | 3 |
Files: | 186,086 |
Messages: | 1,751,440 |