FactMacros contains two compile-time macros which allow the easy creation of a Fact, without having to explicitly repeat
the name of the Fact as an argument.
FactMacros contains two compile-time macros which allow the easy creation of a Fact, without having to explicitly repeat
the name of the Fact as an argument. This makes it easier to define Facts for use in a DSL, as the name of the val to
which it is assigned, becomes the name of the Fact itself.
Without these macros, you would need to create Facts as follows:
val MyFact = new SingularFact[Int]("MyFact")
This redundancy of the Fact's name is not just a nuisance to type, it actually causes trouble when renaming the Fact,
or trying to copy its declaration. In both situations, you *must* also alter the name parameter manually. The compiler
and IDE tooling cannot help you track these errors down and so you are bound to find out about them at runtime, with
potentially uninformative error messages.
If instead, you use these macros, these troubles will be taken away. Define your Facts like this and have the IDE and
compiler warn you about duplicate names etc:
val MyFact = FactMacros.defineFact[Int]("Description")
FactMacros
contains two compile-time macros which allow the easy creation of aFact
, without having to explicitly repeat the name of theFact
as an argument. This makes it easier to define Facts for use in a DSL, as the name of the val to which it is assigned, becomes the name of theFact
itself.Without these macros, you would need to create
Fact
s as follows:val MyFact = new SingularFact[Int]("MyFact")
This redundancy of the
Fact
's name is not just a nuisance to type, it actually causes trouble when renaming theFact
, or trying to copy its declaration. In both situations, you *must* also alter the name parameter manually. The compiler and IDE tooling cannot help you track these errors down and so you are bound to find out about them at runtime, with potentially uninformative error messages.If instead, you use these macros, these troubles will be taken away. Define your
Fact
s like this and have the IDE and compiler warn you about duplicate names etc:val MyFact = FactMacros.defineFact[Int]("Description")