[m-dev.] purity of `:- pragma foreign_proc'

Tyson Dowd trd at cs.mu.OZ.AU
Thu Nov 1 17:23:52 AEDT 2001


On 31-Oct-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 31-Oct-2001, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> > > Before the `:- pragma foreign_proc' syntax becomes widely
> > > used, we should decide what the default purity for foreign
> > > procedures should be. If we are going to make people change
> > > their `:- pragma c_code' declarations to `:- pragma foreign_proc',
> > > we should make any purity annotation changes happen at the same time.
> > > 
> > > At the moment, predicates defined using `:- pragma foreign_proc'
> > > are `pure' by default, but predicates defined using mode-specific
> > > clauses are `impure' by default, even though `:- pragma foreign_proc'
> > > can implement a strict superset of the `impure' behaviour that can be
> > > implemented using mode-specific clauses.
> > 
> > Good point.  Probably impure should be the default.  One simple extension
> > would be to support the syntax
> > 
> > 	:- pragma pure foreign_proc ...
> > 
> > so purity could be concisely specified.  Going further, Mercury could
> > require one of pure, impure, or semipure to always be stated in the
> > foreign_proc declaration, between pragma and foreign_proc.  That approach
> > would get my vote.
> 
> That sounds like a fine approach.
> I think it is slightly preferable to the other two.
> But I'd be happy with any of the three alternatives suggested so far.

Ok, I think we all agree on the semantics (impure by default, require a
promise to make it semipure or pure).  This can be implemented
independently of any syntax changes.


We also think that it would be nice to have a shortcut so that you don't
have to write :- pragma promise_pure(...) when you write a foreign_proc.

Let me collect the syntax proposals together:

(1) :- pragma pure foreign_proc(...).		% or semipure or impure
(2) :- pragma promise_pure foreign_proc(...).   % or promise_semipure

and I'd like to throw in

(3) :- pragma foreign_proc(..., [promise_pure]). % or promise_semipure

Note that with (2) and (3) there doesn't seem to be any need to allow
promise_impure but I guess we could allow it anyway and it would do
absolutely nothing. 

With (1) "impure" would be completely optional and would also make no
difference.

Popularity contest time again.  Please mention if you really care about
the other options too.

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list