[m-rev.] for information: line lengths in generated .cs code

Zoltan Somogyi zoltan.somogyi at runbox.com
Mon May 15 11:36:47 AEST 2023


I wrote these scripts a few days ago, when working on mlds_to_cs_*.m,
and tracking down places where my in-progress changes generated
syntax errors from the C# compiler. Some of those errors were on
very long lines, and I wondered how frequent such lines were. In case
you are also wondering, the output of these scripts from stage2/compiler
after a C# bootcheck are attached.

I spotchecked a few of the lines longer than 400 chars. They fall into
three categories.

One category involves the continuation functions we generate in nondet code
after a nondet goal. These are long because some code using these functions,
which usually have a few arguments, are nevertheless long because each arg
is a field in the env structure, and the fully module qualified name of this env structure
can be quite long. These lines consist of a few (limited by predicate arities) strings
of length 40+.

A second category, which was the rarest, involved functions with *many* args,
such as what we generate for separate_items_in_aug_comp_unit. These lines
consist of 40+ short strings.

The third category involves simple assignment statements where the
value being assigned was a constant string, but the constant string is
itself very long, usually appearing in the source code as a multi-line
string constant. The longest example of this is help_message in
deep_profiler/mdprof_create_feedback.m. In the Mercury source,
this string constant is about 100 lines. In the generated C#, it is
all on one line, because we replace each newline character
in the Mercory source with the backslash-n combo.

Since people don't usually look at generated .cs (or .java, or .c) files,
I don't feel any particular urge to shorten these lines.

Zoltan.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Log.linelen
Type: application/octet-stream
Size: 362 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20230515/553d9950/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.linelen
Type: application/octet-stream
Size: 1918 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20230515/553d9950/attachment-0005.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LINE_LEN_STATS_cs
Type: application/octet-stream
Size: 12914 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20230515/553d9950/attachment-0006.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TOO_LONG_LINES_cs
Type: application/octet-stream
Size: 308936 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20230515/553d9950/attachment-0007.obj>


More information about the reviews mailing list