[m-users.] An inst and an exception

Zoltan Somogyi zoltan.somogyi at runbox.com
Sat Jan 20 02:47:51 AEDT 2024


On 2024-01-20 02:37 +11:00 AEDT, "Volker Wysk" <post at volker-wysk.de> wrote:
> transform(Extr, [Row|Rows], [Data|Rest]) :-     % <- line 1010
>     (
>         if   Data0 = Extr(Row)
>         then
>              Data = Data0,
>              transform(Extr, Rows, Rest)
>         else
>              throw(match_error(Row))            % <- line 1017
>     ).
> 
> 
> I get this from the compiler:
> 
> odbc.m:1010: In clause for `transform(in((func(in) = out is semidet)),
> odbc.m:1010:   in((odbc.one_element_list)), out((odbc.one_element_list)))':
> odbc.m:1010:   mode error: argument 3 had the wrong instantiatedness.
> odbc.m:1010:   Final instantiatedness of `HeadVar__3' was
> odbc.m:1010:   `unique('[|]'(ground, ground))',
> odbc.m:1010:   expected final instantiatedness was
> odbc.m:1010:     named inst one_element_list
> odbc.m:1010:     which expands to
> odbc.m:1010:       bound(
> odbc.m:1010:         '[|]'(
> odbc.m:1010:           ground,
> odbc.m:1010:           named inst exception.[]
> odbc.m:1010:           which expands to
> odbc.m:1010:             bound(
> odbc.m:1010:               []
> odbc.m:1010:             )
> odbc.m:1010:         )
> odbc.m:1010:       ).
> 
> Where does that "unique" come from?

The errror message says that the error is about the third argument
in the clause head. You construct the term [Data | Rest] there,
and since you don't store the reference to that term anywhere else,
that reference is unique. That is NOT the problem.

> What does that "named inst exception.[]"
> mean? Does that error message relate to line 1017?

The error message says that it is not about this clause *in general*;
it is about this clause in the mode of the transform predicate that
promises that the third argument is a one element list. The error
says that the compiler can see that the list has at *least* one element,
but it cannot see why it can't have *more than one* element.
In other words, it expects Rest to be [], but the code computing its value
does NOT promise to return [].

Zoltan.


More information about the users mailing list