Ordering is something we’ve been actively thinking about. We have two loose plans in mind:
- Introduce composite attribute values:
coordinate sub attribute, value [Double, Double]
for example. This should allow for primitive valued lists within an attribute, enums, and possibly other types of structures such as key-value. These would be immutable values, same as our attributes now.
- Introduce ordered connections
We are considering introducing an @ordered
annotation do allow ordering connections as ordered sets
file sub entity,
owns edit-history @ordered;
archive sub entity,
relates content @ordered;
This would preserve all the current semantics of owns
and relates/plays
semantics, but allow writing and reading these connections with control over ordering:
insert
$x isa file, has edit-history [2021-01-01, 2022-01-01] # create initial ordered owns
or alternatively 2 queries with implicit ‘append’ ordering:
insert $x isa file, has edit-history 2021-01-01;
match $x isa file; insert $x has edit-history 2022-01-01;
Insert at position:
match
$x isa file;
insert
$x has edit-history[0] 2020-01-01;
matching the ordered list:
match
$x isa file, has edit-history[] $h;
would return $h = [2020..., 2021..., 2022...]
We imagine if we have ordered collections, they’re indexable:
match
$x isa file, has edit-history[] $h;
$y isa file, has edit-history[0] $h2;
$h[0] = $h2
We can also do something similar for role playing:
insert
$archive (content: [$file0, $file1, $file2]);
# equivalent to a sequential insert appending files to the archive as new role players of `content`
matching ordered role players:
match
$archive (content[]: $c) isa archive;
$c[0] has edit-history[0] 2021...;
Note that if we’re going to allow variables to hold some kind of a set of things, I don’t see why we can’t introduce that feature earlier:
match $x isa file, has edit-history[] $h
could return an unordered set for $h
.
This feature is pretty interesting, early whiteboard days, but we definitely will want something that allows explicit ordering (there will be a cost, such as an extra index).
It’s hard to give an estimate for the time being, but I hope outlining this gives you some ideas of what could be coming up