Add universal to-string conversion builtins (#106)#196
Merged
Conversation
Add 5 new string conversion builtins for all primitive types: bool_to_string, nat_to_string, byte_to_string, float_to_string, and int_to_string (alias for existing to_string). ADT/compound type Show deferred to abilities (#60). Also moves #56 (incremental compilation) from C8e to C8.5. Co-Authored-By: Claude <noreply@anthropic.invalid>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bool_to_string(Bool -> String),nat_to_string(Nat -> String),byte_to_string(Byte -> String),float_to_string(Float64 -> String), andint_to_string(Int -> String)(alias for existingto_string)Implementation details
bool_to_string: Zero allocation — uses interned "true"/"false" from StringPoolbyte_to_string: 1-byte heap allocation, stores byte value as single characterfloat_to_string: 32-byte buffer, integer + fractional digit extraction, trailing zero trimming (keeps at least 1 decimal digit)nat_to_stringandint_to_string: Reuse existing_translate_to_stringimplementationFiles changed (14)
vera/environment.py— 5 new FunctionInfo entriesvera/wasm/calls.py— Dispatch + 3 new translate methodsvera/wasm/inference.py— WASM + Vera return type inferencevera/codegen/modules.py— Cross-module call resolutiontests/test_codegen.py— 12 new tests (5 classes)tests/test_checker.py— 10 new type checker testsexamples/string_ops.vera— New conversion demosspec/04-expressions.md,SKILL.md,vera/README.md— Doc updatesREADME.md— Strikethrough Add universal to-string conversion (Show/Display) for all types #106, move Incremental compilation #56 to C8.5CHANGELOG.md,vera/__init__.py,pyproject.toml— v0.0.64Test plan
pytest tests/ -q)mypy vera/)python scripts/check_examples.py)python scripts/check_version_sync.py)Closes #106