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

Tyson Dowd trd at cs.mu.OZ.AU
Fri Nov 2 13:08:20 AEDT 2001


On 02-Nov-2001, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> On Thu, Nov 01, 2001 at 05:23:52PM +1100, Tyson Dowd wrote:
> > 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.
> 
> A variation on (1) would be to *require* one of pure, semipure or impure.
> No default:  you have to think about it and tell mercury what it is.  That's
> actually what I had intended.
> 
> Naturally, I like (1) best, and (2) a close second.  (If you go with (2)
> promise_pure and promise_semipure will have to be made operators.  But then
> the syntax for promising purity can be
> 
> 	:- promise_pure foo/3.
> 
> which is prettier than the current syntax.)  A compromise between (1) and
> (2), which I'll call (1.5), would be to use
> 
> 	:- pragma promise pure foreign_proc(...).
> 
> and change the promise_pure declarations to
> 
> 	:- pragma promise pure foo/3.
> 
> or even
> 
> 	:- promise pure foo/3.
> 
> I don't care for (3) very much.

I'm going to go for (3).  It is the least intrusive change to make to
the syntax.

I don't think requiring the user to write "impure" is particularly
helpful.  If it is impure they are going to get plenty of reminders
about it when they declare it or use it.   No need to repeat that
information everywhere.

I was very tempted to go with fjh's (0) option (no special syntax) but I
know it will be easier to fix the library with (3) which is a direct
piece of syntax (the promise hangs off the code it applies to).

-- 
       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