Egy egyszerű példa a típus-implementációra: a komplex típus cluster-e.
[cluster; struct; rep; equal; similar; exception] (CLU
forrás)
complex=cluster is create, add, get_x, get_y, get_rho, get_theta,
equal,similar,copy
rep=struct[x,y:real]
create=proc(x,y:real) returns (cvt) signals (overflow,underflow)
return (rep${x:x,y:y})
end create
add=proc(a,b:cvt) returns (cvt) signals (overflow,underflow)
return (rep${x:a.x+b.x, y:a.y+b.y})
resignal overflow,underflow
end add
get_x=proc(c:cvt) returns (real) signals (overflow,underflow)
return (c.x)
end get_x
get_y=proc(c:cvt) returns (real) signals (overflow,underflow)
return (c.y)
end get_y
get_rho=proc(c:cvt) returns (real) signals (overflow,underflow)
return (square_root(c.x*c.x+c.y*c.y))
resignal overflow,underflow
end get_rho
get_theta=proc(c:cvt) returns (real) signals (overflow,underflow)
return (arctangent2(c.x,c.y))
resignal overflow,underflow
end get_theta
equal=proc(c1,c2:cvt) returns (bool)
return (c1=c2)
end equal
similar=proc(c1,c2:cvt) returns (bool)
return (c1=c2)
end similar
copy=proc(c:complex) returns (complex)
return(c)
end copy
end complex