Conversation
170adba to
954817f
Compare
954817f to
3c3ebff
Compare
|
I would like to discuss the syntax for this.
The wildcards act as variables, you're writing a name as a reference to a runtime value identified by that name. In compilation each wildcard gets assigned a number. "Predicate literals" is a feature to choose literal values, but the syntax to me looks more "variable-like" to me. As in, it's not obvious that the compilation will replace To me this feature looks like a C-style macro, where you write a macro name and the preprocessor just replaces it by the literal content of the macro. In C macros are written in upper-case; but here using uppercase would look strange because we're not defining new macros, the predicate names already exist. So here's some ideas for alternative syntax that convey this "macro" idea: |
|
|
|
perhaps |
|
This makes me wonder if other constants could be defined. For example: The same approach could be used for defining other constants, and these could be addressable across modules. This would require that modules also have a "constants" export table, though. |
Closes #491.
This introduces predicate literals, of two kinds:
::pred_name, which can be used for either native or intro predicatesmodule::pred_name, which can be used for external module predicatePredicates from the local module cannot be referred to, to avoid circularity. Predicate literals can be used anywhere that a regular literal can appear, so it's possible to declare them as part of a set, dictionary, or array literal.
In making this PR I also observed that it's possible to create both intro predicates and custom predicates whose names clash with those of native predicates. I have adjusted the parser to reject such names.