[m-users.] ordering of foreign_proc + foreign_code declarations

Zoltan Somogyi zoltan.somogyi at runbox.com
Sun Jul 26 19:35:47 AEST 2020

2020-07-26 18:21 GMT+10:00 "Keri Harris" <keri at gentoo.org>:
> I have a question regarding the (lexical) ordering of foreign_proc +
> foreign_code declarations in a Mercury module. The Mercury Language
> Reference Manual contains the following:
>    Entities declared in ‘pragma foreign_code’ declarations are visible
>    in ‘pragma foreign_proc’ declarations that specify the same foreign
>    language and occur in the same Mercury module. [1]
> It's unclear to me whether this means that a foreign_code declaration
> lexically appearing *after* a foreign_proc declaration in the same
> Mercury module must be visible to that foreign_proc.

Yes, that is correct. The compiler should put all foreign_codes before
all foreign_procs in the target language file it generates.

> Experimentation
> shows that the generated foreign language source file produces
> different orderings depending on the grade:

It seems that you found a bug in the LLDS backend. I am testing a fix
right now; barring unforeseen complications, that fix should be in
tonight's ROTD.


More information about the users mailing list