Top Qs
Timeline
Chat
Perspective
Kaleidoscope (programming language)
Programming language From Wikipedia, the free encyclopedia
Remove ads
Remove ads
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.[1]
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 |
Remove ads
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;
Remove ads
References
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads