"dict"ionary typing?

Alan Baljeu <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
dict and tag are my prefered words.

I guess there are two main uses for a dict:
a) as a struct where there are fixed elements of varying types.
b) as a map where there are variable elements of fixed types.

On another note, I've been thinking the functions should restrict the type of dictionary they operate on.

M.multiply(F) := point{x:X, y:Y} :-
X is M.x*F,
Y is M.y*F.

M should be a point.  But how can I make this explicit?  In fact my preference would be this sort of syntax:

multiply(point{x:X0, y:Y0},F, point{x:X, y:Y}):-
X is X0*F,
Y is Y0*F.

?- Point = point{x:3, y:4}, P2 is Point.multiply(3).

or, 
:- type_decl multiply(point{}, number, point{}).
multiply(In,F,Out) :-
Out.x is In.x *F,
Out.y is In.y *F.

and then also have type declaration for dict.  

Alan Baljeu
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.