show renders to a string instead of printing - #94
Merged
Merged
Conversation
(print (show x)) -- the natural idiom -- failed with "Expected 1 args, found values #inert": show wrote showVal to the console itself and returned inert, so print then rejected show's return value. A printing primitive wearing a renderer's name, and redundant with write besides. show now returns the printed representation as a string and writes nothing. Rendering grants no host authority, so the HostIO gate is gone: show exists under every profile (the CLR fault sweep's four (show value) cases move from capability errors to values). It carries a certified contract, (show any) -> string, pure. The five in-repo call sites that used show as a printer -- zipper, contracts, and vau-dotnet examples, IronKernel.Test's show-line, and the website's trace sample -- become (print (show ...)), preserving their output byte for byte. The operators reference now documents the rendering semantics.
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.
The bug
(print (show x))— the idiom everyone reaches for — printed the value and then failed withExpected 1 args, found values #inert, blamed on the whole form. Root cause:showwas a printing primitive wearing a renderer's name. It wroteshowValto the console itself and returned#inert;printthen correctly rejected#inert. The output people saw came fromshow, notprint. It was also redundant:writealready prints machine-readable representations, and the language had no way to render a value to a string.The fix
shownow returns the printed representation as a string and writes nothing:HostIOgate is removed —showexists under every profile, includingminimal. (The CLR fault sweep reflects this: its four(show value)cases move from capability errors to returned values, 172/47 → 168/51, withfaulted: 0unchanged.)(show any) → string, pure — visible incontract-of, LSP hover, and completion detail.(show)and extra arguments areNumArgserrors (it previously ignored extras).Call-site migration (all five in-repo uses were show-as-printer; each becomes
(print (show …)), preserving output byte for byte):Examples/zipper.ikr×2,Examples/contracts.ikr,Examples/vau-dotnet.ikr,lib/IronKernel.Test'sshow-line, and the website'stracesample. The operators reference now documents the rendering semantics.Breaking change, deliberately: external code using bare
(show x)to print will now compute and discard the string. The old semantics were unreachable through the name (Haskell'sshow, and the docs' own "printed representation" framing, both promise rendering), and pre-1.0 is when this gets fixed.Verification
--no-incrementalrebuild: zero warnings. Full suite: 454/454 (3 new: rendering + the exact regression idiom viaevalSessionKernel;showunderminimalwithprintstill denied as the control; a script-level two-form regression asserting the captured output equals(1 2)(3 4)).faulted (process aborted): 0with the four-case shift fully accounted for.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.