Skip to content

Allow negations and disjunctions without an exterior binding #292

Open
@james-whiteside

Description

@james-whiteside

Problem to Solve

Currently, the following queries are illegal:

Example 1:

match
$j isa journal, has name "Acta Materialia";
not { $p isa publication, has paper-id "1234"; };
insert
$p isa publication, has paper-id "1234";
(journal: $j, publication: $p) isa publishing;

Example 2:

match
{ $j isa journal, has name "Acta Materialia"; } or { $j isa journal, has name "Acta Mater."; };
insert
$p isa publication, has paper-id "1234";
(journal: $j, publication: $p) isa publishing;

This is because the negation and disjunction blocks are currently illegal in match clauses without at least one binding from within the block also bound outside of the block.

Current Workaround

In some cases, the query can be modified without much impact to readability and still produce identical results, for instance:

Example 2:

match
$j isa journal;
{ $j has name "Acta Materialia"; } or { $j has name "Acta Mater."; };
insert
$p isa publication, has paper-id "1234";
(journal: $j, publication: $p) isa publishing;

But in others, the simplest approaches that produces identical results under all circumstances is far less readable, and very unintuitive to construct for non-expert users:

Example 1:

match
$j isa journal, has name "Acta Materialia";
$p-type type publication;
not { $p isa $p-type, has paper-id "1234"; };
insert
$p isa publication, has paper-id "1234";
(journal: $j, publication: $p) isa publishing;

It should be possible to find a workaround in any case, so this does not affect language expressivity.

Proposed Solution

Allow negation and disjunction blocks without any bindings within the block also bound outside. Some cases of this are not logically sound queries, but they should be possible to distinguish when the query is parsed and throw an exception, as opposed to the current behaviour which is to reject all such queries indiscriminately.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions