-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slices and printfs #37
Labels
Comments
I lied, the layout of a slice currently is |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently the compiler automatically converts a
str
to its pointer when passing it to a C-style vararg function (eg.printf
) (seeflax/source/codegen/call.cpp
Line 193 in 8402c46
Of course this kinda defeats the purpose, since slices are not necessarily null-terminated. The proposed alternative (which I'm proposing now) is to pass the entire struct to
printf
, which will cause it to get both the length and the pointer.(aside: the layout of
str
is like this:struct str { len: i64; ptr: &i8 }
)Then, we would need to call
printf
with%.*s
instead of just%s
.The text was updated successfully, but these errors were encountered: