[m-dev.] Update library pragma C code

Tyson Dowd trd at stimpy.cs.mu.oz.au
Sat Aug 1 10:37:11 AEST 1998


On 01-Aug-1998, Peter Schachte <pets at students.cs.mu.oz.au> wrote:
> On Fri, 31 Jul 1998, Thomas Charles CONWAY wrote:
> 
> > 	Convert
> > 		:- pagma(c_code, ...
> > 	to 
> > 		:- pagma c_code(...
> > 	
> > 	and introduce will_not_call_mercury in places where it is implicit
> > 	(this is in preparation for changing the default to may_call_mercury).
> 
> Interesting.  I was just thinking that it would be good if the compiler
> could determine which predicates might do trailing, so that the
> extra overhead in choicepoint handling in tr grades could be avoided (at
> least sometimes).  The problem is that all trailing ultimately happens in C
> code, and there's no mechanism for telling the Mercury system whether or
> not a bit of C code might do trailing or not.  As far as I can see, there's
> no way to convince the C compiler to tell us, so if we want to (ever be able
> to) do this sort of optimization, there will have to be a way for users to
> declare this.
> 
> The reason I mention this now is that I was thinking that the current
> may_call_mercury/will_not_call_mercury labeling is really a bit too limited,
> and while you're monkeying with this stuff anyway would be a good time to
> generalize it a bit more.  I think it would be better if that sort of info
> were given as a list of "tags", so that the set of possible tags could be
> expanded with the evolution of Mercury.  I'd like to propose the addition of
> may_trail/will_not_trail as the first extension.

Tom's change doesn't change much -- it's just changing older syntax
to newer syntax (and "new" isn't very new).

It's likely that the entire foreign language interface could
become something more like:

:- pragma foreign(c, foo(X::out), tags, ".....").

So you can use different languages (e.g. C++ and Fortran in particular),
and it will put them in separate files and compile them with the
appropriate compilers & linkers.

-- 
       Tyson Dowd           # "Bill Gates is a white persian cat and a monocle
                            # away from becoming another James Bond villan."
     trd at cs.mu.oz.au        # "No Mr Bond, I expect you to upgrade."
http://www.cs.mu.oz.au/~trd #                -- Dennis Miller and Terri Branch



More information about the developers mailing list