[m-users.] Problem with higher-order pred passed as argument

Sean Charles (emacstheviking) objitsu at gmail.com
Tue Jan 25 01:48:48 AEDT 2022


You see Julien, I am not that adventurous yet!

That’s great, I’ll take that on board immediately… I did read a question recently similar to this from somebody wanting to store predicates in a structure as part of a game project IIRC. I’ll re-read that too.

Many thanks
Sean


> On 24 Jan 2022, at 14:46, Julien Fischer <jfischer at opturion.com> wrote:
> 
> 
> On Tue, 25 Jan 2022, Zoltan Somogyi wrote:
> 
>> To tell it the modes, you should define an inst such as
>> 
>> :- inst tpu_inst
>>   --->    loads(ground)
>>   ;       vartype
>>   ;       identifier
>>   ;       callterm(ground, ground, ground)
>>   ;       t_indent(pred(in, out) is det).
>> 
>> and then specify the mode of the Op argument as "in(tpu_inst)".
> 
> An alternative to defining the above inst would be to use a combined
> higher-order type and inst, see section 8.3.3 of the reference manual.
> For example:
> 
>    :- type tpu_inst
>    --->    loads(ps)
>    ;       vartype
>    ;       identifier
>    ;       callterm(felt_options, int, call_term)
>    ;       t_indent(pred(tpu_state::in, tpu_state::out) is det).
> 
> Julien.



More information about the users mailing list