Line comments versus line splicing [entries|reading|network|archive]
simont

[ userinfo | dreamwidth userinfo ]
[ archive | journal archive ]

Wed 2013-06-19 14:02
Line comments versus line splicing
LinkReply
[personal profile] fanfWed 2013-06-19 18:52
Another option is to put the continuation marker at the start of the next line, and allow it to take effect across multiple preceding comment-only or whitespace-only lines. Eg:
OBJECTS = one.o
\\          two.o # This object is notable for some reason
\\          three.o
# the next two objects must not be reordered
\\          four_a.o
\\          four_b.o
# end of reordering constraint
\\          five.o
#\\         six.o # removed until bug 1234 is fixed
\\          seven.o
\\          eight.o
Link Reply to this | Thread
[personal profile] fanfWed 2013-06-19 19:25
And another option (which I think BCPL has) is to pair continuation markers at the end and start of the spliced lines. Any white space and/or comments between the splice markers is deleted. You could also specify that bracketed comments such as /* */ have these semantics.
Link Reply to this | Parent | Thread
[personal profile] fanfWed 2013-06-19 19:49
In fact, backslash-newline is redundant in C (if you don't use it to split tokens, which is evil) because its pertinent uses can be replaced by a /* \n */ comment or by a "..." \n "..." string continuation.
Link Reply to this | Parent | Thread
[personal profile] gerald_duckThu 2013-06-20 00:11
Indeed. I made that observation when I bumped into Simon in the pub this evening.

There is just one place I can think of where backslash-newline is nonetheless needed: splitting a #include filename across multiple lines. Why doesn't the preprocessor concatenate all strings that follow the #include directive to make the filename? I concluded some hysterical raisins might be involved. (ISTR encountering a compiler once upon a time that had a non-standard optional second parameter.)
Link Reply to this | Parent | Thread
[personal profile] fanfThu 2013-06-20 08:38
Good point - though if you need to split a #include like that then something has gone horribly wrong :-)

Also, #include delenda est: http://www.infoq.com/news/2012/11/llvm-modules
Link Reply to this | Parent
[personal profile] simontThu 2013-06-20 08:53
I ought to have thought of that myself, since the disgusting mkfiles.pl script that I use to manage the many makefiles for my portable free software uses that technique. Ahem.
Link Reply to this | Parent
navigation
[ go | Previous Entry | Next Entry ]
[ add | to Memories ]