-
-
Notifications
You must be signed in to change notification settings - Fork 88
Description
Design Proposal: Debug expression
Motivation
When writing complex expressions, I sometimes have a logic bug and need to debug my expression. Most programming languages have some sort of "print statement debugging" trivially available to debug things even without a dedicated debugger tool. The expression system has no feature available, other than assigning some value to a SymbolLayer's text field to display it on the map.
Proposed Change
A new expression, perhaps called println
or debug-log
or something, that takes one or two parameters. When it's evaluated, it simply logs to stdout (native) or console (browser) whatever value it received on the first parameter, and returns that same value. If the second parameter was provided, it's a string label for the log line.
This way, the style writer can wrap any portion of an expression with println
to log the output of that expression, or wrap a large expression with multiple println
s with different labels to really understand what might be going on.
It's not really intended to be used in production styles; just while developing a style.
Signature: ["println" value label?] -> value
API Modifications
^
Migration Plan and Compatibility
Nothing to migrate; fully backwards compatible.
Rejected Alternatives
- As described above but name it
log
: would be confusing with math expressionslog10
andlog2
. - No new expression; just continue using SymbolLayer text as before to get some debug output. This is unwieldy, especially if I want to log multiple values.