[m-dev.] pragma stub proposal

Ian MacLarty maclarty at csse.unimelb.edu.au
Thu Aug 13 13:44:26 AEST 2009

On Thu, Aug 13, 2009 at 12:47 PM, Peter
Schachte<schachte at csse.unimelb.edu.au> wrote:
> 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:
>>>> 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).
>> You wouldn't provide the clause in the presence of this pragma.
> How about allowing an optional second argument to the pragma to specify the
> error message?  So you could distinguish between "Not yet implemented" and
> "Not available in this grade."  Or, if those are the only two reasons you can
> think of for stubs, just provide two different pagmas, like unavailable/1 and
> unimplemented/1.

What I eventually ended up doing was the following:

% First define dummy Mercury types for the Java foreign_types.
% These are necessary for when a stub has to output a foreign value.
:- type jdbc_db ---> jdbc_db.
:- type jdbc_cursor ---> jdbc_cursor.

% Now define det_error, so we can throw an exception in the stub
without getting a warning:
:- pred det_error(string::in, io::di, io::uo) is det.
det_error(Msg, !IO) :-
    ( semidet_succeed ->

% Now define the stub for non-Java grades:
jdbc_get_dbms_name(_, "", -1, "", !IO) :- det_error("non-Java grade", !IO).

I guess this isn't too bad really.


mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au

More information about the developers mailing list