Skip to content

Clean up pointer dereferences to use auto-deref dot access and upgrade examples to print macros - #12

Merged
CierCier merged 2 commits into
mainfrom
std/cleanup-dot-access-and-examples
Jul 21, 2026
Merged

CierCier merged 2 commits into
mainfrom
std/cleanup-dot-access-and-examples

Conversation

@CierCier

@CierCier CierCier commented Jul 21, 2026 •

Copy link
Copy Markdown
Owner

Automated refactoring of stdlib and examples to use the compiler-supported auto-dereference dot access for pointers instead of explicit (*self).x patterns. Also upgrades C printf calls in examples to modern compiler-builtin print macros.

Greptile Summary

This PR adopts pointer auto-dereference access and builtin print macros. The main changes are:

  • Replaces explicit pointer dereferences across the standard library and bootstrap mirror.
  • Changes File.valid and File.invalid to pointer receivers.
  • Converts example output from printf to @print and @println.
  • Regenerates the checked-in bootstrap compiler and library artifacts.

Confidence Score: 5/5

The code changes look mergeable after preserving the intended example output.

  • Pointer auto-deref replacements retain the prior source-level operations.
  • Generic floating-point formatting drops explicit decimal precision in several examples.
  • Boolean formatting changes one example from numeric to textual output.

examples/casting.ag and examples/struct_attributes.ag

Important Files Changed

Filename Overview
std/io.ag Uses auto-deref field access and changes file validity helpers to pointer receivers.
std/slice.ag Replaces explicit slice pointer dereferences with auto-deref access.
std/rt/value.ag Uses auto-deref method calls for nested optional values.
std/rt/methods.ag Uses auto-deref access for runtime object and type metadata.
examples/casting.ag Moves casting output to generic formatting and loses explicit floating-point precision.
examples/struct_attributes.ag Moves attribute output to typed formatting, changing boolean output from numeric to textual.
bootstrap/bin/agc Regenerates the checked-in bootstrap compiler binary.
bootstrap/lib/silver/std/io.agm Regenerates the module artifact associated with the updated standard I/O source.

Reviews (1): Last reviewed commit: "Update bootstrap artifacts after stdlib ..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

Context used:

  • Context used - You are an expert systems programmer, compiler eng... (source)

Copilot AI review requested due to automatic review settings July 21, 2026 10:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CierCier
CierCier merged commit 7699b2a into main Jul 21, 2026
1 check passed
@CierCier
CierCier deleted the std/cleanup-dot-access-and-examples branch July 21, 2026 10:25
Comment thread examples/casting.ag
f64 z = 3.14159;
i32 w = (i32)z;
printf("f64 %.5f as i32: %d\n", z, w);
@println("f64 {} as i32: {}", z, w);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Fixed Precision Is Lost

This example previously printed z with exactly five decimal places. The generic {} formatter has no precision setting and routes the value through the default floating-point formatter, so the casting example can now produce different output for the same value.

Suggested change
@println("f64 {} as i32: {}", z, w);
printf("f64 %.5f as i32: %d\n", z, w);

Context Used: You are an expert systems programmer, compiler eng... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

printf("c: id=%d flag=%d\n", c.id, c.flag);
@println("p: ({}, {})", p.x, p.y);
@println("v: ({}, {})", v.x, v.y);
@println("c: id={} flag={}", c.id, c.flag);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Boolean Representation Changes

The old %d conversion printed flag as 0 or 1, while the builtin boolean formatter prints false or true. Running this example with the current flag = true initialization therefore changes the demonstrated output from flag=1 to flag=true.

Suggested change
@println("c: id={} flag={}", c.id, c.flag);
@println("c: id={} flag={}", c.id, (i32)c.flag);

Context Used: You are an expert systems programmer, compiler eng... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

CierCier added a commit that referenced this pull request Aug 1, 2026
Clean up pointer dereferences to use auto-deref dot access and upgrade examples to print macros
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