Defining constants as "macro" for expansion


I have a list of numerical constants I want to use in the code. I am blanking on whether I can define these constant using a constant symbol that, then gets expanded into the number whenever used in the code – via preprocessing.

Can this be done?



You can define clauses for goal_expansion/2 that will expand is/2 goals and arithmetic comparison goals (=:=/2, =\=/2, </2, …), replacing the constants with their values.