modus icon indicating copy to clipboard operation
modus copied to clipboard

Nullary Predicate Syntax

Open mechtaev opened this issue 3 years ago • 3 comments

Currently, nullary predicates are denoted as identifiers without parentheses, e.g. a :- b, c. @maowtm suggested to consider using the syntax with (), e.g. a() :- b(), c(). The parentheses can also be optional. Here are my thoughts about this:

Without parentheses

  • Plus: The same as in Prolog, XSB Datalog
  • Plus: Similar to the names of build stages in Dockerfiles
  • Minus: Non-intuitive for the majority of users, because the majority is not familiar with Prolog.

With parentheses

  • Plus: Intuitive for the majority of users
  • Plus: The same as in Souffle Datalog
  • Minus: When used as image predicates, something like ubuntu might be more intuitive than ubuntu(), since it is just a reference to an image, and not a call

With optional parentheses

  • Plus: Most flexible
  • Minus: It might be non-intuitive that a :- b(), c is the same as a() :- b, c()

@barr , @thevirtuoso1973 , what are your thoughts about it?

mechtaev avatar Nov 20 '21 19:11 mechtaev

A related thought: maybe we can solve the user error problem by making sure that we have clear error messages. When I tried a :- b() or a :- b::c() by mistake (not knowing this was not allowed) the error message did not provide any useful information. Maybe we should have a special case for this - check if there is () following a predicate, and specifically say something like "parenthesis should be omitted for nullary predicates"...?

maowtm avatar Nov 20 '21 19:11 maowtm

I am in favour of enforcing parentheses for nullary predicates. Although I don't mind the other options.

I think the relational algebra operators would all work the same way, just that we'd be working on {()} or {}. So to be consistent, enforce p().

Regardless, it would improve readability if we just stuck to one (instead of making it optional).

thevirtuoso1973 avatar Nov 20 '21 20:11 thevirtuoso1973

Just my personal opinion... but I actually prefer no parenthesis if we have to enforce either one or the other, since being able to just write thing :- other_thing is quite satisfying :smile:

maowtm avatar Nov 20 '21 20:11 maowtm