Skip to content

destructuring

Andrew Matthews edited this page Aug 30, 2025 · 1 revision

Destructuring Patterns

  • The language needs a syntax for representing the structure of graphs to allow #binding of "names" to #graph components
  • new_name = 'bob'
    
    create Alice:
    def init(new_name):
      name(new_name)
    
    {name = {x}} = alice
    
    # x should contain 'bob'
  • An interesting issue will be how to get to info that sits in a graph that is in scope. With #sparql, this would be something you find using a select query. How to get to the data without needing to produce big intrusive queries? Perhaps a special namespace such as "here" that could search whatever graphs are in scope.
  • ?bob.like(alice) <= here;
  • might be interpreted to mean; fill the variable bob with whatever resource can be found in the scope here matching the pattern <?bob, like, alice>
  • this would constitute some sort of variable declaration of a variable called Bob, pre-populated with data from the ground state Graph or whatever graph is in scope.
  • question: what do you do if there are more than one resource that matches the pattern you defined? Should you deliver a list of matching resources and have Bob be a collection? this seems to be a pretty fundamental issue when there is absolutely nothing stopping me from turning a single property into multiple instances of the property by simply stating variance of the same fact or assertion. Should every kind of thing be assumed to be a list or can every type do double duty as both a bit single instance of the type in multiple instances. Perhaps every operation could be interpreted as an iteration over whatever matching instances are found.
  • perhaps one could provide a linguistic mechanism to explicitly state that there can be only one instance of a thing, with presumably the implication that if multiple names are used to refer to properties then these names must refer to the same thing.

Clone this wiki locally