arturo-lang / grafito

Portable, Serverless & Lightweight SQLite-based Graph Database in Arturo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better syntax for node creation/query helpers?

drkameleon opened this issue · comments

Right now, we have (let's say the "helper" is: person)

  • Create a new node (with just a name/title): person.new "John"
  • Create a new node (with various properties): person.new [name: "John" surname: "Doe"]
  • Query a new node (name only): person "John"
  • Query a new node (with various rules): person [surname: "Doe"]

I don't particularly dislike this person.new thing, but it still looks quite verbose. To be honest, I would prefer something like person! (for creating) and person for querying, or person (for creating) and person? for querying. That's just an example.

Both make sense, but both have their own issues. 🤔

For example:

  • The former's issue is that ! cannot be part of an identifier (it's the only really reserved character in Arturo - it's an accepted symbol actually - but I have managed to "keep it for later"; mainly the idea would probably be to use it as a preprocessor symbol, but that's a different story...)
  • The problem with the later is that normally identifiers ending in ? in Arturo mean: "do that and expect a boolean value will be returned" (= "predicate"). So, it would kind of break our own - not too bad - rule.

Another issue is that we may actually - in practice I mean - need more complicated queries.

For instance, in the different experiments I've done, I usually need something along the lines of: "get this node or create it if it doesn't exist". This can be done right now with: person.new.unique [name: "John" surname: "Doe"], but well... if person.new looks verbose to me, I can't start to explain why this looks like an... encyclopedia).

So, so, so... Open for discussion! :)