[m-rev.] for review: Allow external files to be included in foreign_decl and foreign_code.
Julien Fischer
jfischer at opturion.com
Mon Mar 17 11:44:29 AEDT 2014
On Thu, 13 Mar 2014, Peter Wang wrote:
> (diff -b)
>
> Allow external files to be included in pragma foreign_decl and pragma
> foreign_code declarations:
>
> :- pragma foreign_decl("Lang", include_file("Path")).
> :- pragma foreign_decl("Lang", local, include_file("Path")).
> :- pragma foreign_code("Lang", include_file("Path")).
>
> where Path may be an absolute path to a file or a path relative to the
> directory that contains the source file of the module containing the
> declaration.
>
> mmc --make takes include_file into account when computing dependencies.
> Mmake is unchanged yet.
...
> diff --git a/doc/reference_manual.texi b/doc/reference_manual.texi
> index a7a34b2..525aa26 100644
> --- a/doc/reference_manual.texi
> +++ b/doc/reference_manual.texi
> @@ -9522,6 +9522,7 @@ The University of Melbourne Mercury implementation supports the following
> extensions to the Mercury language:
>
> @menu
> +* Foreign include files:: Including foreign code from external files.
> * Fact tables:: Support for very large tables of facts.
> @c XXX STM
> @c The documentation of STM is commented out because its support is
> @@ -9545,6 +9546,29 @@ extensions to the Mercury language:
> @c implementation-specific...
> @c * Reserved tag:: Support for Herbrand constraint solvers.
>
> + at node Foreign include files
> + at section Foreign include files
>
> +Foreign declarations and code may be included from external files
> +using extensions of the @samp{pragma foreign_decl} and
> + at samp{pragma foreign_code} declarations:
> +
> + at example
> +:- pragma foreign_decl("@var{Lang}", include_file("@var{Path}")).
> +:- pragma foreign_decl("@var{Lang}", local, include_file("@var{Path}")).
> +:- pragma foreign_code("@var{Lang}", include_file("@var{Path}")).
> + at end example
Why is this feature an implementation-dependent extension rather than
just a normal part of the foreign language interface?
> +
> +These have the same effects as the standard forms except that the
> +contents of the file referenced by @var{Path} are included in place of
> +the string literal in the last argument, without further interpretation.
> + at var{Path} may be an absolute path to a file or a path relative to the
> +directory that contains the source file of the module containing the
> +declaration. The interpretation of the path is platform-dependent.
I can understand why that might be the case with absolute paths, but
with relative paths too?
> +
> +The @samp{mmc --make} tool takes @samp{include_file} references into
> +account when computing dependencies.
Cheers,
Julien.
More information about the reviews
mailing list