[m-rev.] for review: implement pragma foreign_export

Ian MacLarty maclarty at csse.unimelb.edu.au
Wed Jul 19 16:51:01 AEST 2006


On Wed, Jul 19, 2006 at 03:54:08PM +1000, Julien Fischer wrote:
> 
> On Wed, 19 Jul 2006, Ian MacLarty wrote:
> 
> >On Wed, Jul 19, 2006 at 02:09:28PM +1000, Julien Fischer wrote:
> >>>>doc/reference_manual.texi:
> >>>>	Add a new section to the foreign language interface chapter
> >>>>	documenting the new pragma.
> >>>>
> >>>>	Update the descriptions of the language specific bindings to include
> >>>>	the new pragma.
> >>>>
> >>>>tests/hard_coded/Mmakefile:
> >>>>tests/hard_coded/pragma_foreign_export.{m,exp}:
> >>>>	Make sure that we can parse the new syntax and run a simple program
> >>>>	that uses exported procedures.
> >>>>
> >>>
> >>>Are you planning to replace all uses of ":- pragma export" in the
> >>>compiler (such as in browser/declarative_debugger.m) with the new pragma
> >>>in a subsequent diff?
> >>>
> >>
> >>Not immediately.
> >
> >But it seems that your diff has replaced ":- pragma export" with
> >":- pragma foreign_export" in error messages.  Will I get an error about
> >a ":- pragma foreign_export" now if I have an error in a ":- pragma
> >export"?
> 
> Yes.
> 
> >If so, then that's a bug.
> 
> It's not a very important bug ... it's the same bug that reports errors in
> foreign_proc pragmas when there is a bug in a pragma c_code declaration.  If
> you feel strongly about it I can fix it but I don't think that it's worth
> it.
> 

No I don't feel strongly about it.

> >I propose you fix that bug by
> >disallowing ":- pragma export" as soon as the new compiler has been
> >installed on our Mercury machines.
> 
> We won't be doing that for backwards compatibility reasons.  Support for
> pragma export will be removed along with support for pragma c_code,
> pragma c_header_code etc.
> 

Okay.

> >>>>Index: doc/reference_manual.texi
> >>>>===================================================================
> >>>>RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
> >>>>retrieving revision 1.357
> >>>>diff -u -r1.357 reference_manual.texi
> >>>>--- doc/reference_manual.texi	5 Jul 2006 08:45:37 -0000	1.357
> >>>>+++ doc/reference_manual.texi	12 Jul 2006 08:05:27 -0000
> >>>>@@ -6071,6 +6071,9 @@
> >>>>				       or function as a call to code
> >>>>				       written in a different
> >>>>				       programming language.
> >>>>+* Calling Mercury from foreign code::  How to call a Mercury predicate
> >>>>+                                       or funciton from a different
> >>>>+                                       programming language.
> >>>>* Using foreign types from Mercury::   How to use a type defined in
> >>>>				       a different programming language
> >>>>				       in Mercury code.
> >>>>@@ -6388,6 +6391,41 @@
> >>>>
> >>>>@c
> >>>>-----------------------------------------------------------------------
> >>>>
> >>>>+ at node Calling Mercury from foreign code
> >>>>+ at section Calling Mercury from foreign code
> >>>>+
> >>>>+Mercury procedures may be exported so that they can be called by code
> >>>>written
> >>>>+in a foreign language.
> >>>>+
> >>>
> >>>I think you need to clarify that the foreign code that calls the Mercury
> >>>code must in turn have been called from Mercury code, or alternatively
> >>>the user needs to take steps to initialize the Mercury runtime before
> >>>calling the exported procedure.
> >>
> >>Yes, but I'm not going to do that as a part of this diff.  Currently
> >>the only documentation we can point a user to for doing that is the
> >>code in samples.  I'm planning to write a new section for the user's
> >>guide on initialising the runtime as part of the standalone libraries
> >>change - I'll update this section then.
> >>
> >
> >I still think it at least say that calling exported Mercury procedures
> >from foreign code that's not called from Mercury code originally is not
> >yet supported.  Reading the doc I'd expect to be able to call the
> >exported proc from my C program, but that won't work at the moment.
> 
> Yes it will.  See samples/c_interface/simpler_c_calls_mercury.
> 

Oh, okay.  I thought there was a problem because the runtime needs
initializing, but if it works then okay.

Ian.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at csse.unimelb.edu.au
administrative address: owner-mercury-reviews at csse.unimelb.edu.au
unsubscribe: Address: mercury-reviews-request at csse.unimelb.edu.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at csse.unimelb.edu.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list