Relations & goals
rel defines a callable relation. A newline between goals acts like conjunction, while and and or make logical composition explicit.
rel permitted(x)
known(x) and not blocked(x)Cosmos is an indentation-sensitive relational language: familiar expressions and data meet unification, goals, backtracking, and composable relations. Edit a sample below, then run it in the browser.
This workbench runs an experimental JavaScript interpreter for a useful Cosmos subset; it does not yet include the full compiler or SWI-Prolog runtime.
Run the sample or make it your own.
Cosmos combines relational programming with concise, readable syntax and targets Prolog as its intermediate runtime. Follow the project for source releases and ongoing language work.
Open the Cosmos projectSwitch between small visual programs, run or pause the loop, and use the source as a starting point for Cosmos graphics.
space.canvas(640, 360)
center = {x=320, y=180}
rel draw(t)
space.clear("#07101f")
space.circle(center.x, center.y, 34, "#c8f06b")
space.circle(center.x + cos(t) * 110,
center.y + sin(t) * 70, 12, "#86e6c6")
space.start(draw)Interactive preview of the Space-style canvas API. The animation runs locally in this page.
Browse published packages and releases on SourceForge.
A compact guide to the concepts that make Cosmos different, followed by the executable grammar supported in this browser lab.
rel defines a callable relation. A newline between goals acts like conjunction, while and and or make logical composition explicit.
rel permitted(x)
known(x) and not blocked(x)= unifies patterns and values. Lists, dictionaries, strings, numbers, and functors can all participate in structured programs.
person = {name="Mira", roles=[reader, maker]}
head = [first | rest]if, while, and next provide direct control syntax while preserving a relational core.
i = 0
while i < 3
print(i)
next i = i + 1Protocols describe the fields and relation modes an object provides. Objects can use a prototype while remaining ordinary tables.
Protocol(Moving,{
Number x
rel move(In Number dx, In Number dy)
})Search the productions implemented by this page.
program ::= { declaration | statement }