Repository navigation
Clean up pointer dereferences to use auto-deref dot access and upgrade examples to print macros - #12
Conversation
…ot access and upgrade examples to print macros
| f64 z = 3.14159; | ||
| i32 w = (i32)z; | ||
| printf("f64 %.5f as i32: %d\n", z, w); | ||
| @println("f64 {} as i32: {}", z, w); |
There was a problem hiding this comment.
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.
| @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); |
There was a problem hiding this comment.
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.
| @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!
Clean up pointer dereferences to use auto-deref dot access and upgrade examples to print macros
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:
File.validandFile.invalidto pointer receivers.printfto@printand@println.Confidence Score: 5/5
The code changes look mergeable after preserving the intended example output.
examples/casting.ag and examples/struct_attributes.ag
Important Files Changed
Reviews (1): Last reviewed commit: "Update bootstrap artifacts after stdlib ..." | Re-trigger Greptile
Context used: