Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Disallowed line-breaks

33 views
Skip to first unread message

Janis Papanagnou

unread,
Jul 25, 2016, 12:14:15 PM7/25/16
to
I was slightly astonished (without inspecting the documentation, granted)
when I got syntax errors (tested with gawk) in an expression like

(
( f() && g() ) ||
( h() && i() )
) && (
( j() && k() ) ||
( l() && m() )
)

I needed to rewrite that - keeping the boolean operators always at the
end, and no opening parenthesis alone on or at the end of a line - to

( ( f() && g() ) ||
( h() && i() ) ) &&
( ( j() && k() ) ||
( l() && m() ) )

thereby sacrificing readability. (The real program has longer function
names, where readability is even more of concern, because the structure
is even less visible than in the above sample.)

I wonder why the rules are that strict in case of arithmetic expressions
with clear (line-)continuation conditions in the presense of parenthesis.

Janis

Aharon Robbins

unread,
Jul 25, 2016, 2:56:29 PM7/25/16
to
In article <nn5dsm$650$1...@news-1.m-online.net>,
Janis Papanagnou <janis_pa...@hotmail.com> wrote:
>I wonder why the rules are that strict in case of arithmetic expressions
>with clear (line-)continuation conditions in the presense of parenthesis.

The grammar doesn't understand nested parentheses. The rules for
line continuation are clearly documented in the manual. You can _always_
use backslash continuation to cause awk to treat the end of line like
a space.
--
Aharon (Arnold) Robbins arnold AT skeeve DOT com

Janis Papanagnou

unread,
Jul 26, 2016, 8:30:41 AM7/26/16
to
On 25.07.2016 20:56, Aharon Robbins wrote:
> In article <nn5dsm$650$1...@news-1.m-online.net>,
> Janis Papanagnou <janis_pa...@hotmail.com> wrote:
>> I wonder why the rules are that strict in case of arithmetic expressions
>> with clear (line-)continuation conditions in the presense of parenthesis.
>
> The grammar doesn't understand nested parentheses. The rules for
> line continuation are clearly documented in the manual.

Yes. (I seem to recall, though, that GNU awk is more tolerant with where
line continuation is possible if compared to old (or even POSIX) awk. Am
I mistaken?)

> You can _always_
> use backslash continuation to cause awk to treat the end of line like
> a space.

Backslash continuation (which can be done on a lexical level) is an
inferior concept compared to syntactical structuring, can be error prone,
and often does not support readability. I therefore avoid it.

Janis

0 new messages