Here's a suggestion. I got a strange syntax error because I was loking at the book
and copying and forgot to copy (...) as [...], due to the syntax change to Alloy4.
It gave me an error on a comma and said it expected a ). Of course putting that in
is wrong.
My suggestion is that you run several of the old alloy programs through the new parser,
to find common syntax errors that result from the change of () to [] for predicates
and functions, and then change the syntax error recovery of your parser so that it
suggests to the user that perhaps they may have forgotten to use [] in such cases.
Another thought on this. It's more of a difference from Alloy3, but
perhaps you should consider (or allow) the use of square brackets []
to declare functions and predicates. It's a bit odd to use () in declarations
and use [] when applying the function or predicate...
That's a very good suggestion. I will try to improve the syntax error messages.
And you were right with your second suggestion as well:
indeed predicate definitions can use "[ ]" as well as "( )".
So the following is a legal definition:
pred equal [a, b: univ] { a = b }
And in fact, if there are no parameters,
we can leave out the [ ] or ( ) entirely.
perhaps you should consider (or allow) the use of square brackets []
to declare functions and predicates. It's a bit odd to use () in declarations
and use [] when applying the function or predicate...
Gary T. Leavens
in the declarations of predicates and functions.
So never mind this second suggestion.
Gary T. Leavens
That's a very good suggestion. I will try to improve the syntax error messages.
And you were right with your second suggestion as well:
indeed predicate definitions can use "[ ]" as well as "( )".
So the following is a legal definition:
pred equal [a, b: univ] { a = b }
And in fact, if there are no parameters,
we can leave out the [ ] or ( ) entirely.
pred atLeastTwoNodes { ! lone Node }
Sincerely,
Felix Chang
Alloy4 Developer