-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hi! I suggest a new idea, conditional printing.
Current state
(mate/dreduce + [1 3 5 7 9]) (as an example) will print all the stages to stdout.
Problem
- Printing is time consuming
- The developer writes the code especially for debugging
- Need to change the code for production in order not to have the time consuming printing
Suggested Solution
What if the developer will not have to change the production code and in the same time will not suffer from printing? Sounds good to be true? Sounds like conditional printing!
The whole idea is that during runtime we can decide whether or not to print. I suggest 3 methods to do that:
- Printing Levels:
Every macro can take an optional printing level ∈ #{0 1 2 3 4 5}. This level must be >=mate/*min-level*for printing to occur.
For example:
(mate/dreduce {:level 3} + [1 3 5 7 9]) ; Only activates printing when (>= 3 *min-level*) A developer can setmate/min-level by mate/set-min-level!
- Namaspace Filtering:
Prints can be elided or filtered by the namespace in which they occur.
For example, a developer can call
(mate\set-ns-patterns! {:whitelist #{"foo.bar.*"} :blacklist #{"bar.foo.*"}})- Arbitrary Runtime Conditions:
Each macro supports an optional arbitrary test expression:
(mate/dreduce {:when my-cond?} + [1 3 5 7 9]) ; Only activates printing when `my-cond?` is truthyThat's it, thanks :)
This idea and suggested solution was inspired by tufte profiler
Metadata
Metadata
Assignees
Labels
No labels