mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 06:14:59 +00:00
This diff contains no algorithmic changes.
Estimated hours taken: 8 Branches: main This diff contains no algorithmic changes. It merely renames apart a bunch of function symbols to reduce ambiguity. Basically I went through prog_data.m, prog_item.m, hlds_data.m, hlds_goal.m and hlds_pred.m looking for type definitions containing function symbol names that were either language "keywords" (e.g. "terminates", which is an annotation on foreign_procs), used with slightly different meanings in several types (e.g. "sym"), or both (e.g. "call"). When I found such type definitions, I changed the names of the function symbols, usually by adding a prefix or suffix indicating the type to all function symbols of the type. For example, the old function symbol "foreign_proc" in type "pragma_type" is now named "pragma_foreign_proc", and the names of all other function symbols in that type also start with "pragma_". All of this should yield simpler compiler error messages when we make mistakes, and will make it more likely that looking up a function symbol using a tags file will take you to the actual definition of the relevant instance of that function symbol. However, the most important benefit is the increase in the readability of unfamiliar code; the reader won't have to emulate the compiler's type ambiguity resolution algorithm (which in many cases used to require distinguishing between f/14 and f/15 by counting the arguments, e.g. for "pred_or_func"). compiler/prog_data.m: compiler/prog_item.m: compiler/hlds_data.m: compiler/hlds_goal.m: compiler/hlds_pred.m: Rename function symbols as explained above. compiler/*.m: Conform to the function symbol renames. In some cases, rename other function symbols as well. Minor style fixes, e.g. replace if-then-elses with switches, or simple det predicates with functions.
This commit is contained in:
@@ -77,8 +77,6 @@
|
||||
% with module qualifiers separated by the standard Mercury module
|
||||
% qualifier operator.
|
||||
%
|
||||
:- pred sym_name_and_arity_to_string(sym_name_and_arity::in, string::out)
|
||||
is det.
|
||||
:- func sym_name_and_arity_to_string(sym_name_and_arity) = string.
|
||||
|
||||
:- pred write_simple_call_id(simple_call_id::in, io::di, io::uo) is det.
|
||||
@@ -264,14 +262,11 @@ write_quoted_sym_name(SymName, !IO) :-
|
||||
write_sym_name(SymName, !IO),
|
||||
io.write_string("'", !IO).
|
||||
|
||||
sym_name_and_arity_to_string(SymName/Arity, String) :-
|
||||
sym_name_and_arity_to_string(SymName/Arity) = String :-
|
||||
sym_name_to_string(SymName, SymNameString),
|
||||
string.int_to_string(Arity, ArityString),
|
||||
string.append_list([SymNameString, "/", ArityString], String).
|
||||
|
||||
sym_name_and_arity_to_string(SymName/Arity) = String :-
|
||||
sym_name_and_arity_to_string(SymName/Arity, String).
|
||||
|
||||
write_simple_call_id(simple_call_id(PredOrFunc, Name, Arity), !IO) :-
|
||||
Str = simple_call_id_to_string(PredOrFunc, Name, Arity),
|
||||
io.write_string(Str, !IO).
|
||||
|
||||
Reference in New Issue
Block a user