Unary and binary modes?

@herme, thanks for the writeup. Your ideas are closer to mine than I expected :slight_smile: I’m a bit confused about unary and binary though as you write the unary without an argument and the binary with a single (type) argument.

Note that SWI-Prolog PlDoc uses Mode ArgName [:Type], e.g., open(++File:atom, ++Mode, --Stream). At least, that is how it should be written as the ++ and – are specified in SWI-Prolog’s notational conventions, but rarely used.

Hi Jan, thanks. In the draft with ‘unary’ modes I was just referring to the fact that, when translated to Prolog code, in assertions, etc., they correspond to unary properties, such as nonvar(Arg1), var(Arg2), etc. This comes in particular from the translation of modes into assertions in Ciao Prolog. For example a machine readable comment such as:

 %! length(+,-): Computes the length of a list.

or this equivalent assertion:

 :- pred length(+,-) # "Computes the length of a list.".

are both translated in Ciao to the following assertion:

:- pred length(X,Y) : nonvar(X) => nonvar(Y) # "Computes the length of a list.".

(which means: “when calling length, X should be nonvar and if length succeeds then Y should be nonvar”).

However, I can see how it may be a bit confusing to read that + has arity 1, so I have reworded the draft to not refer to any mode arities. Hopefully it is all clearer now, thanks for spotting this.

Regarding also including types, in Ciao the combination of types or other properties modes can be done for example like this:

 %! length(+list,-int): Computes the length of a list.

This is slightly different from SWI but as Jose has pointed out it seems easy to come to an agreement or support both versions. Anyway, these are two somewhat separate things that we can work towards agreeing on: the meaning of the modes and the syntax.