The trace operation

Purpose

The trace operation in Pile is a simple yet powerful debugging tool designed to provide quick feedback during development. It serves as a "value checker" that helps identify potential issues in your program by outputting the current value on top of the stack to the console.

Usage

The trace operation outputs the value at the top of the stack, allowing you to verify intermediate states in your program. Here's how it works:

  1. The value at the top of the stack is displayed.
  2. The stack remains unchanged (no items are popped).

Examples

"This text" trace
# The previous text is still on the stack, that's why it is possible to concatenate now
"This is concatenated with " +

1 1 + trace
# Result: int 2
# Stack: [ 2 ]