7. String Interpolation #
✅ IMPLEMENTED: String interpolation is fully implemented and working with comprehensive test coverage.
7.1 Syntax #
String interpolation uses ${}
syntax within double-quoted strings:
let name = "Alice"
let age = 30
let message = "Hello ${name}, you are ${age} years old"
7.2 Expression Support #
Any expression is valid inside interpolation:
let x = 10
let y = 5
print("Sum: ${x + y}")
print("Product: ${x * y}")
print("Complex: ${(x + y) * 2 - 1}")
7.3 Type Handling #
- String variables: Use
%s
format specifier - Integer expressions: Use
%ld
format specifier - Function calls: Supported for single-parameter functions
7.4 Implementation #
Interpolated strings are compiled to:
- Allocate a buffer (
alloca [1024 x i8]
) - Use
sprintf
to format the string - Use
puts
to output the result