Page 1 of 1

compound domains as return values?

Posted: 8 Apr 2018 21:57
by daveplummermd
Hello

Is it possible to declare a procure in an interface to a class that returns a compound domain?
Such as:

Code: Select all

interface X getDates()->dates Dates. end interface X
where the return domain is defined:

Code: Select all

domains dates = d (integer,integer,integer).
Thanks in advance,
Dave

Re: compound domains as return values?

Posted: 8 Apr 2018 23:08
by Harrison Pratt
VIP 7 & 8 forbid naming domains and facts with the same name, unlike VIP 5x. This seems like an annoyance when you are upgrading your code and thinking from 5x, but it will save you debugging time in the future.

This sort of approach works:

Code: Select all

class dateStore : dateStore     open core end class dateStore

Code: Select all

implement dateStore     open core facts     date_fact : ( integer, integer, integer ). clauses     tryGetDate() = date(M,D,Y) :-         date_fact(M,D,Y),         !. end implement dateStore

Code: Select all

interface dateStore     open core domains    dateDOM = date( integer, integer, integer ). predicates     tryGetDate : () -> dateDOM determ. end interface dateStore
Also, shouldn't dates = d (integer,integer,integer). in your example be date = d (integer,integer,integer) ?

Re: compound domains as return values?

Posted: 15 Apr 2018 22:16
by daveplummermd
Thanks so much.