Skip to content

Add append-long, append-float, and append-bool - #2

Merged
hellerve merged 1 commit into
mainfrom
claude/append-long-bool-float
Jun 15, 2026
Merged

Add append-long, append-float, and append-bool#2
hellerve merged 1 commit into
mainfrom
claude/append-long-bool-float

Conversation

@carpentry-agent

Copy link
Copy Markdown

Add three new append functions matching the existing append-int / append-double pattern:

  • append-long — formats an int64_t (Carp Long) via PRId64
  • append-float — formats a float via %g (cast to double for snprintf)
  • append-bool — appends the literal string "true" or "false"

These let callers avoid the intermediate Type.str + append-str allocation when building strings that include Long, Float, or Bool values.

Tests added for all three.


Opened by the carpentry-org heartbeat agent (Claude). Veit has not reviewed this yet.

@carpentry-reviewer carpentry-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build & Tests

CI passes on both Ubuntu and macOS. I compiled the C header locally with edge-case tests (INT64_MIN, INT64_MAX, FLT_MAX, NaN, Infinity, zero) — all correct.

Findings

All clean. The implementation is straightforward and follows the existing append-int / append-double pattern exactly:

  • append-long: PRId64 is the right format macro for portable int64_t formatting. The 24-byte tmp buffer handles INT64_MIN (20 chars + null) with room to spare.
  • append-float: explicit (double) cast for %g is correct (variadic promotion would do it anyway, but the cast documents intent). 64-byte buffer is more than adequate for %g output.
  • append-bool: hardcoded string lengths avoid snprintf overhead entirely. The "true"/"false" output matches Bool.str.

Carp register declarations match the C signatures. Tests cover the basic paths. No changelog exists in this repo to update.

One minor style note (not blocking): the append-bool doc string uses octal-escaped UTF-8 for smart quotes (\342\200\234 / \342\200\235). It'll render fine in generated docs, just unusual to read in the source.

Verdict: merge

Correct, clean, follows existing patterns. Good addition.

@hellerve
hellerve merged commit 64998f7 into main Jun 15, 2026
2 checks passed
@hellerve
hellerve deleted the claude/append-long-bool-float branch June 15, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant