[m-rev.] for post-commit review: foreign_code_to_identifiers

Peter Wang novalazy at gmail.com
Tue Jan 27 17:54:49 AEDT 2026


On Tue, 27 Jan 2026 16:57:35 +1100 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> Rename and restructure c_code_to_name_list.
> 
> compiler/foreign.m:
>     Rename c_code_to_name_list to foreign_code_to_identifiers,
>     which describes its job much better. Make it take the language
>     of the foreign code as input, though we ignore it for now.
>     Also rename the predicates in its call tree accordingly.
> 
>     Restructure foreign_code_to_identifiers's call tree to ensure
>     tail recursion in loops that may be long enough for that to matter.
> 
> compiler/make_hlds_warn.m:
>     Conform to the changes above.

> @@ -511,55 +515,58 @@ filter_exports(WantedLang, Exports0, LangExports, NotLangExports) :-
>  
>  %-----------------------------------------------------------------------------%
>  
> -c_code_to_name_list(Code, List) :-
> -    string.to_char_list(Code, CharList),
> -    c_code_to_name_list_2(CharList, List).
> +foreign_code_to_identifiers(_Lang, Code, Indentifiers) :-
> +    string.to_char_list(Code, Chars),
> +    % We use cords to ensure tail recursion in the loop over Code,
> +    % because it may be big. We do not do try to ensure tail recursion
> +    % for loops over identifiers, since (for cultural reasons)
> +    % they will effectively never be long enough for this to be a problem.
> +    foreign_code_to_identifiers_loop(Chars, cord.init, IndentifierCord),
> +    Indentifiers = cord.list(IndentifierCord).
>  

s/Indentifier/Identifier everywhere.

The rest is fine.

Peter


More information about the reviews mailing list