zaphar / ucg

A Universal Configuration Grammar
Apache License 2.0
36 stars 3 forks source link

Declarative Compile Errors. #30

Closed zaphar closed 5 years ago

zaphar commented 5 years ago

Now that we have the is operator for type checking the only missing piece for declarative schema checks is a way to throw compile errors declaratively.

Ideally we would check some boolean value and provide a useful compile message. So the declarative operator should probably take a tuple payload that contains both a message similar to the assert keyword. The main difference is that the new syntax should abort with an error as expected.

fail "Expected string field foo! in struct";

If we introduce a declarative compile failure then we inevitably want to ask if we should be able to trap those failures somehow. My gut says no but it's possible that we will have a good use case for this in the future sometime. If we we can look at introducing that feature then.