Skip to content

Document typecasting - #424

Open
miharp wants to merge 3 commits into
OpenVoxProject:masterfrom
miharp:docs/lang-typecasting-407
Open

Document typecasting#424
miharp wants to merge 3 commits into
OpenVoxProject:masterfrom
miharp:docs/lang-typecasting-407

Conversation

@miharp

@miharp miharp commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Adds a page covering conversion between data types, the last of the missing pages identified in #407.

The language collection had nothing explaining how to turn a value of one type into a value of another. The page covers:

  • Calling a data type as a constructor, its equivalence to the new function, positional and named arguments, and how constrained types such as Integer[0] check the result
  • Conversion to numbers, including radix detection and the explicit radix argument, float truncation, and the absolute-value argument
  • Conversion to strings, format directives, and the six-decimal default for floats
  • Conversion to booleans, and the fixed vocabulary it accepts rather than any notion of truthiness
  • Conversion between arrays and hashes, including the wrap-unless-already-an-array form and the Tuple / Struct variants
  • Extracting numbers from longer text with scanf
  • Automatic coercion in arithmetic, and why explicit conversion is preferable to relaxing strict

It links into the generated function.html#new reference rather than restating every conversion signature.

The page is wired into _data/nav/openvox_8x.yml and the index in lang_data.md.

Verification

  • Every example was run against OpenVox 8.28.1 with puppet apply: 60 value assertions checked against their stated output, plus 6 error cases. The three error messages quoted in the page match the runtime text verbatim.
  • markdownlint-cli2 reports no issues.
  • bundle exec jekyll build is clean, and rake test:links passes across 455 files, including the #automatic-coercion-in-arithmetic anchor.

Two behaviors documented here differ from the upstream new() docstring and the Puppet Core typecasting page, so they are worth a reviewer's attention:

  • The docstring gives Float.new and Numeric.new an $abs default of true. At runtime the default is false, so Numeric('-42.3') returns -42.3 rather than 42.3. The page documents the runtime behavior.
  • Automatic string-to-number coercion in arithmetic is an error by default, because strict defaults to error. The page shows explicit conversion rather than suggesting the setting be relaxed.

The page describes conversion as something you ask for rather than something Puppet never does, because two exceptions are real: arithmetic coerces strings to numbers when strict is not error, and interpolation converts any value to a string even under strict=error. Both are signposted from the top of the page.

Content is original prose in the existing lang_* house style. help.puppet.com was used as a coverage reference only, not copied.

Part of #407

@miharp
miharp requested a review from a team as a code owner July 23, 2026 11:26
Copilot AI review requested due to automatic review settings July 23, 2026 11:26

Copilot AI 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.

Pull request overview

Adds the missing “Typecasting” documentation page to the OpenVox 8.x language docs, closing the remaining data-type documentation gap tracked in #407 by describing explicit value conversion patterns and linking into the generated new() reference.

Changes:

  • Added a new lang_typecasting.md page documenting common conversions (constructor-style calls, number/string/boolean/array/hash conversions, scanf, and strictness-related coercion behavior).
  • Added a cross-link from the “About values and data types” page to the new Typecasting page.
  • Added a sidebar navigation entry for the new Typecasting page.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
docs/_openvox_8x/lang_typecasting.md New documentation page covering explicit type conversions and coercion notes.
docs/_openvox_8x/lang_data.md Adds a pointer from the data overview to the new Typecasting page.
_data/nav/openvox_8x.yml Adds the Typecasting entry to the OpenVox 8.x navigation sidebar.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/_openvox_8x/lang_typecasting.md Outdated
Copilot AI review requested due to automatic review settings July 23, 2026 11:33

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

miharp and others added 2 commits July 27, 2026 07:14
The language collection had no page covering conversion between data
types. Add lang_typecasting.md, covering calling a data type as a
constructor, conversion to numbers, strings, booleans, arrays and
hashes, extracting numbers with scanf, and automatic coercion in
arithmetic.

Every example is verified against OpenVox 8.28.1 with puppet apply.
Two behaviors documented here differ from what the upstream new()
docstring and the Puppet Core typecasting page describe:

* The docstring gives Float.new and Numeric.new an $abs default of
  true; at runtime the default is false, so Numeric('-42.3') returns
  -42.3 rather than 42.3.
* Automatic string-to-number coercion in arithmetic is an error by
  default, because the strict setting defaults to error. The page
  shows explicit conversion instead of relaxing the setting.

Conversion is described as something you ask for rather than something
Puppet never does, since arithmetic coerces strings to numbers when
strict is not error, and interpolation converts any value to a string
even under strict=error. Both exceptions are signposted from the top of
the page.

Part of OpenVoxProject#407

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Michael Harp <mike@mikeharp.com>
The section documents both arithmetic coercion and string interpolation,
but the heading named only arithmetic, so the pointer from the top of the
page under-described where it led. Drop the qualifier and update the
in-page link.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Michael Harp <mike@mikeharp.com>
@miharp
miharp force-pushed the docs/lang-typecasting-407 branch from 2525571 to b410edf Compare July 27, 2026 11:14
Copilot AI review requested due to automatic review settings July 27, 2026 11:14

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread docs/_openvox_8x/lang_typecasting.md Outdated
The Integer section said the radix applies when converting a string, but
the absolute-value example passed an Integer with a radix of 10, which
reads as inconsistent.

Integer has a single positional dispatch, (from, radix, abs), where the
radix is typed Variant[Default, Integer[2,2], Integer[8,8],
Integer[10,10], Integer[16,16]]. A Boolean cannot occupy that slot, so
Integer(-38, true) is an argument-mismatch error and the radix must be
supplied to reach the third argument even when it does not apply. The
upstream new() docstring advertises a two-argument
Integer.new(Variant[Numeric, Boolean], Boolean) overload that the
dispatch does not implement.

Keep a working example, add a string case where the radix genuinely
applies, and use default as the placeholder for non-string input. Say
positionally why the argument is there.

Verified against OpenVox 8.28.1 with puppet apply.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Michael Harp <mike@mikeharp.com>
Copilot AI review requested due to automatic review settings July 27, 2026 11:31

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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.

2 participants