pku-msv-lab / modus

A language for building Docker/OCI container images
GNU Affero General Public License v3.0
280 stars 9 forks source link

Nullary Predicate Syntax #52

Open mechtaev opened 2 years ago

mechtaev commented 2 years ago

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

With parentheses

With optional parentheses

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

maowtm commented 2 years ago

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"...?

thevirtuoso1973 commented 2 years ago

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).

maowtm commented 2 years ago

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: