{{Short description|Programming language}} The '''Kaleidoscope programming language''' is a [[constraint programming]] language embedding [[constraint satisfaction problem|constraints]] into an [[imperative programming|imperative]] [[Object-oriented programming|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.<ref>{{Cite web |last=Lopez |first=Gus |last2=Freeman-Benson |first2=Bjorn |last3=Borning |first3=Alan |date=1993 |title=Kaleidoscope: A Constraint Imperative Programming Language |url=https://constraints.cs.washington.edu/cip/kaleidoscope-asi.pdf |access-date=2023-12-30 |website=constraints.cs.washington.edu}}</ref> {| class="wikitable" |- ! !! Kaleidoscope'90 !! Kaleidoscope'91 !! Kaleidoscope'93 |- | Constraint Evaluation || Lazy || Eager || Eager |- | Variables || Hold streams || Hold streams || Imperative |- | Concurrent Constraints || Strict || Strict || Non-strict |- | Syntax || Smalltalk-like || Algol-like || Algol-like |- | Constraint Model || Refinement || Refinement || Perturbation |- | Method Dispatching || Single || Multiple || Multiple |- | Assignment || As a constraint || As a constraint || Destructive |}

==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;

==References==

*{{cite book | first=Gus | last=Lopez |author2=Bjorn Freeman-Benson |author3=Alan Borning | chapter=Kaleidoscope: A Constraint Imperative Programming Language | title=Constraint Programming | publisher=Springer-Verlag | pages=313–329 | year=1994 }} *{{cite book | first=Kim | last=Marriott |author2=Peter J. Stuckey | title=Programming with constraints: An introduction | year=1998 | publisher=MIT Press }} {{ISBN|0-262-13341-5}} <references/>

[[Category:Procedural programming languages]] [[Category:Constraint programming]] [[Category:Constraint programming languages]]

{{compu-lang-stub}}