Skip to content
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

std.fmt.format: tuple parameter instead of var args #3873

Merged
merged 7 commits into from
Dec 9, 2019

Conversation

andrewrk
Copy link
Member

@andrewrk andrewrk commented Dec 9, 2019

Related: #208

Note that this is unrelated to C var args compatibility.

@andrewrk andrewrk added breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library. labels Dec 9, 2019
@giann
Copy link
Contributor

giann commented Dec 9, 2019

Too bad this requires an empty struct when no parameters.

@andrewrk
Copy link
Member Author

andrewrk commented Dec 9, 2019

On the contrary, that is a feature! Yes, it takes a few more keystrokes when writing code. It does not feel as clean. However, when reading code, there is a 1:1 mapping between every callsite parameter and every function definition parameter.

When reading code that does not take advantage of format arguments, it is obvious how to edit the code to add format parameters. And, most importantly, an entire language feature can be deleted. There is no wondering how var args works, because it does not exist.

Block labels being required to return values from blocks is similarly unpopular, yet it teaches how to use block labels. The empty argument to formatted printing teaches how to use tuples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants