[m-rev.] diff: shorten C# identifiers

Peter Wang novalazy at gmail.com
Fri Oct 8 12:52:45 AEDT 2010


Branches: main

compiler/mlds_to_cs.m:
        Shorten C# identifiers to 511 characters to be accepted by the
        Microsoft compiler.

diff --git a/compiler/mlds_to_cs.m b/compiler/mlds_to_cs.m
index ed5b506..9cb30fd 100644
--- a/compiler/mlds_to_cs.m
+++ b/compiler/mlds_to_cs.m
@@ -1687,12 +1687,13 @@ output_name(EntityName, !IO) :-
 :- pred write_identifier_string(string::in, io::di, io::uo) is det.
 
 write_identifier_string(String, !IO) :-
-    % Although the C# spec does not limit identifier lengths, both the
-    % Microsoft and Mono compilers restrict identifiers to 512 characters.
+    % Although the C# spec does not limit identifier lengths, the Microsoft
+    % compiler restricts identifiers to 511 characters and Mono restricts
+    % identifiers to 512 characters.
     Length = string.length(String),
     ( Length > 511 ->
         Left = string.left(String, 251),
-        Right = string.right(String, 251),
+        Right = string.right(String, 250),
         Hash = string.hash(String) /\ 0xffffffff,
         io.format("%s_%08x_%s", [s(Left), i(Hash), s(Right)], !IO)
     ;

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list