Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
Kaleidoscope (programming language)
Constraint programming language embedding constraints into an imperative object-oriented language

The Kaleidoscope programming language is a constraint programming language embedding constraints into an imperative object-oriented language. It adds keywords always, once, and assert..during (formerly while..assert) to make statements about relational invariants. Objects have constraint constructors, which are not methods, to enforce the meanings of user-defined datatypes.

There are three versions of Kaleidoscope which show an evolution from declarative to an increasingly imperative style. Differences between them are as follows.

Kaleidoscope'90Kaleidoscope'91Kaleidoscope'93
Constraint EvaluationLazyEagerEager
VariablesHold streamsHold streamsImperative
Concurrent ConstraintsStrictStrictNon-strict
SyntaxSmalltalk-likeAlgol-likeAlgol-like
Constraint ModelRefinementRefinementPerturbation
Method DispatchingSingleMultipleMultiple
AssignmentAs a constraintAs a constraintDestructive
We don't have any images related to Kaleidoscope (programming language) yet.
We don't have any YouTube videos related to Kaleidoscope (programming language) yet.
We don't have any PDF documents related to Kaleidoscope (programming language) yet.
We don't have any Books related to Kaleidoscope (programming language) yet.
We don't have any archived web articles related to Kaleidoscope (programming language) yet.

Example

Compare the two code segments, both of which allow a user to drag the level of mercury in a simple graphical thermometer with the mouse.

Without constraints:

while mouse.button = down do old <- mercury.top; mercury.top <- mouse.location.y; temperature <- mercury.height / scale; display_number( temperature ); if old < mercury.top then delta_grey( old, mercury.top ); elseif old > mercury.top then delta_white( mercury.top, old ); end if; end while;

With constraints:

always: temperature = mercury.height / scale; always: white rectangle( thermometer ); always: grey rectangle( mercury ); always: display number( temperature ); while mouse.button = down do mercury.top = mouse.location.y; end while;
  • Lopez, Gus; Bjorn Freeman-Benson; Alan Borning (1994). "Kaleidoscope: A Constraint Imperative Programming Language". Constraint Programming. Springer-Verlag. pp. 313–329.
  • Marriott, Kim; Peter J. Stuckey (1998). Programming with constraints: An introduction. MIT Press. ISBN 0-262-13341-5

References

  1. Lopez, Gus; Freeman-Benson, Bjorn; Borning, Alan (1993). "Kaleidoscope: A Constraint Imperative Programming Language" (PDF). constraints.cs.washington.edu. Retrieved 2023-12-30. https://constraints.cs.washington.edu/cip/kaleidoscope-asi.pdf