[m-users.] Cannot execute a predicate from a Discriminated Union

Charles Shuller charles.shuller at gmail.com
Sun Jun 28 11:19:05 AEST 2015


Awesome!

The weirdness in execute_test/2 is a result of me chopping out everything
that wasn't needed to repro the compiler error.   The original was similar
to what you have suggested.

I notice the fix comes as an inst declaration and then specifying that inst
on the mode for execute_test.   So is it not possible to assign the inst of
the pred on a type to a type?

Thanks again everyone!! I've been fighting with this since last night.


Charles

On Sun, Jun 28, 2015 at 1:07 AM, Tomas By <tomas at basun.net> wrote:

> On Sun, June 28, 2015 02:56, Charles Shuller wrote:
> > Also does not work.
>
> The attached version compiles.
>
> This bit:
>
> | execute_test(Test, Disposition) :-
> |   call(Test^test_pred, Disposition),
> |   Disposition = fail(Test^test_name ++ " Failed to execute").
>
> is strange - Disposition is an out parameter, and you seem to be trying to
> assign a value to it twice. My version just ignores the return value of
> the call.
>
> You could do something like:
>
> | execute_test(Test, Disposition) :-
> |   call(Test^test_pred, D),
> |   ( D = pass ->
> |     Disposition = pass
> |   ; Disposition = fail(Test^test_name ++ " Failed to execute") ).
>
>
> /Tomas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20150628/7a8dd729/attachment.html>


More information about the users mailing list