[m-dev.] pragma stub proposal

Paul Bone pbone at csse.unimelb.edu.au
Thu Aug 13 14:09:47 AEST 2009


On Wed, Aug 12, 2009 at 04:00:45PM +1000, Ian MacLarty wrote:
> On Wed, Aug 12, 2009 at 3:22 PM, Julien
> Fischer<juliensf at csse.unimelb.edu.au> wrote:
> >
> > On Wed, 12 Aug 2009, Ian MacLarty wrote:
> >
> >> I recently wrote a binding to JDBC in Mercury.  To avoid errors when
> >> compiling the module in C grades (the module could still be linked in
> >> even if it isn't used) I added stub versions of the Java foreign procs
> >> like so:
> >>
> >> jdbc_get_dbms_name(_, _, _, _, !IO) :- error("non-Java grade").
> >>
> >> The problem with this is that I then get a determinism warning, since
> >> it is inferred erroneous.
> >>
> >> The other option is to use --allow-stubs and --no-warn-stubs, but that
> >> will create stubs for *all* predicates without any clauses,
> >> potentially hiding real errors.
> >>
> >> What I would prefer is to be able to tell the compiler to create stubs
> >> for a specific set of predicates with a pragma.  For example:
> >>
> >> :- pragma stub(jdbc_get_dbms_name/6).
> >
> > So you wouldn't provide the above clause in the presence of this pragma?
> > Or do you use the pragma as well as the clause and the effect of the
> > pragma is just to disable the warning for that predicate?
> >
> 
> You wouldn't provide the clause in the presence of this pragma.

This makes sense.  Perhaps you want an unimplemented pragma.  If the compiler
finds foreign procedures it should make a stub that throws an exception
"Unimplented in this grade." or similiar and if there are no foreign procs it
could just say "Unimpleted".  I also like Peter's suggestion because you get
compile time checking.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 489 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/developers/attachments/20090813/028fa697/attachment.sig>


More information about the developers mailing list