Skip to content

Observations on in(char) and out(number) Command Behaviors #3

@Hjokrenl

Description

@Hjokrenl

Hello,

First of all, thank you for creating and maintaining this excellent Piet interpreter. It's a very robust and well-structured project.

I'm opening this issue to report some observations on the behavior of two commands, in(char) and out(number), which seem to differ from common expectations for Piet interpreters and can impact how certain programs are designed.

  1. The in(char) command appears to skip all whitespace characters.

When using the in(char) command, any whitespace characters in the standard input (such as spaces, tabs, or newlines) seem to be consumed and discarded by the interpreter. The command only pushes the next non-whitespace character onto the stack.

This behavior makes it impossible for a Piet program to read and process these characters. For example, a common technique is to read characters within a loop that terminates when a newline character (stack value 10) is detected. With the current implementation, this pattern is not feasible because the newline is never passed to the program, which can lead to unexpected infinite loops.

  1. The out(number) command automatically appends a newline character.

When the out(number) command is executed, it prints the number from the top of the stack to standard output, followed immediately by a newline character.

The Piet language specification does not appear to mandate this automatic newline. This behavior prevents programs from controlling their output formatting, such as printing a sequence of numbers on a single line separated by spaces or other characters.

I wanted to bring these behaviors to your attention for your consideration. They represent deviations from what many Piet programmers might expect and place certain constraints on the types of programs that can be written.

Thank you again for your time and for your great work on this project.

Best regards.
(By using Gemini-2.5-pro)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions