m4: Other Incompatibilities
1
1 16.3 Other incompatibilities
1 ============================
1
1 There are a few other incompatibilities between this implementation of
1 'm4', and the System V version.
1
1 * GNU 'm4' implements sync lines differently from System V 'm4', when
1 text is being diverted. GNU 'm4' outputs the sync lines when the
1 text is being diverted, and System V 'm4' when the diverted text is
1 being brought back.
1
1 The problem is which lines and file names should be attached to
1 text that is being, or has been, diverted. System V 'm4' regards
1 all the diverted text as being generated by the source line
1 containing the 'undivert' call, whereas GNU 'm4' regards the
1 diverted text as being generated at the time it is diverted.
1
1 The sync line option is used mostly when using 'm4' as a front end
1 to a compiler. If a diverted line causes a compiler error, the
1 error messages should most probably refer to the place where the
1 diversion was made, and not where it was inserted again.
1
1 divert(2)2
1 divert(1)1
1 divert`'0
1 =>#line 3 "stdin"
1 =>0
1 ^D
1 =>#line 2 "stdin"
1 =>1
1 =>#line 1 "stdin"
1 =>2
1
1 The current 'm4' implementation has a limitation that the syncline
1 output at the start of each diversion occurs no matter what, even
1 if the previous diversion did not end with a newline. This goes
1 contrary to the claim that synclines appear on a line by
1 themselves, so this limitation may be corrected in a future version
1 of 'm4'. In the meantime, when using '-s', it is wisest to make
1 sure all diversions end with newline.
1
1 * GNU 'm4' makes no attempt at prohibiting self-referential
1 definitions like:
1
1 define(`x', `x')
1 =>
1 define(`x', `x ')
1 =>
1
1 There is nothing inherently wrong with defining 'x' to return 'x'.
1 The wrong thing is to expand 'x' unquoted, because that would cause
1 an infinite rescan loop. In 'm4', one might use macros to hold
1 strings, as we do for variables in other programming languages,
1 further checking them with:
1
1 ifelse(defn(`HOLDER'), `VALUE', ...)
1
1 In cases like this one, an interdiction for a macro to hold its own
1 name would be a useless limitation. Of course, this leaves more
1 rope for the GNU 'm4' user to hang himself! Rescanning hangs may
1 be avoided through careful programming, a little like for endless
1 loops in traditional programming languages.
1