Hello,
I think that mm-ADT has new data type.
sequence: zero or more objects.
…where the two collections are a type of sequence:
list: an integer-based index of a sequence.
map: an object-based index of a sequence.
Why does a sequence exist? It exists because we don’t have a name for this
anonymous type:
@object*
The above type/pattern is one of two things:
1. A multi-referent reference.
2. A sequence.
Given that references are implicitly dereferenced, I don’t think we should mix
references in our patterns as references ultimately are the thing they are
referencing.
As such @object* is a “sequence.” Its not a list, because a list is typed as:
[@object*]
And what is that really saying? — its saying that a list is container of a
sequence. What is the nature of that container? integer-based indexing.
A sequence is like a “structureless list.” Why? Because these are the only
mutation instructions that work on it:
1. [append,@object]
2. [delete,@object]
You can’t [insert] because there is no way to say where to insert — there are
no indices.
Finally, if “sequence" is the name of @object*, then I think a reference can be
redefined to only allow one-to-one linking.
[db][&value,people]
This doesn’t return a reference to zero or more person objects. No, it returns
a reference to a single sequence. Likewise, with respects to indexing:
-> [has,name,eq,$x.@string] => &person*
We have a reference to zero or more persons — a sequence of persons.
Finally, this also means that the following types are subtypes of sequence as
they are all subtypes of @object*.
@object{2}
@object?
@object{5,100}
@object+
@object{0}
@object
With respect to the last type, this means that every denoted thing is a
sequence.
‘hello'
That is a sequence of one element that is a string — i.e. @string. Or, more
specifically, @‘hello’.
This then means that [append] and [delete] can be applied everywhere that
supports 0 or >1 quantification.
[constant,’hello’] // ‘hello'
[append,42] // ‘hello’ 42
[append,’marko’] // ‘hello’ 42 ‘marko'
[delete,’hello’] // 42 ‘marko'
What scares me is that we don’t have a way of representing instances of a
multi-element sequence in our language. The below is ambiguous with sequences
of containers.
[name:marko, projects:tinkerpop,lop,gremlin]
Maybe we do:
[name:marko, projects:<tinkerpop,lop,gremlin>]
…where
[name:marko]
<=>
[name:<marko>]
…or perhaps:
[name:marko, projects:(tinkerpop,lop,gremlin)]
Its a pattern match group.
Finally, realize that this gets at a problem that I can’t seem to solve without
the concept of a “sequence” (a containerless collection). And if you say that
“sequences” are just lists, then bytecode will be a nasty tangle of [unfold]
instructions — and overly complex reference graphs.
Thoughts?,
Marko.
http://rredux.com <http://rredux.com/>