-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add posix.getopt() interator-based interface #19179
Conversation
I think a simple arg parser in |
Thanks for the feedback! I have at least some tendency to agree with most of your points, for the most part. I've already seen (and used!), for example https://github.com/Hejsil/zig-clap , which is more in the spirit of a "much better than getopt" argument parser. I'd love to see something more like that in std, somewhere. My goals here with this patch/debate are really around things like:
|
I think best case scenario for this patch is it lands in |
I'm fine with any logical home for it. On that front though: I thought |
yes |
I think this usecase is niche enough that APIs to support it can go in a third-party package. The standard library should focus on idiomatic Zig interfaces, and low-level OS primitives, rather than emulating C APIs. |
Well, clearly I'm in the minority here and I'll withdraw. But for the record: the world of C software using legacy POSIX interfaces currently dwarfs the world of idiomatic Zig software. I would have thought that a goal would be to make language ports of existing C software easier in order to foster adoption. Thanks for taking the time! |
This implements getopt() in std.posix. It's a bit of an oddball case in some ways that may or may not be worth discussing:
getopt(3)
is part of the POSIX standard, and widely used in the C/POSIX world, but...posix.getopt()
, it maybe makes for an interesting side-point in the discussions around the rename std.os to std.posix #5019 and Eliminate the POSIX API layer #6600.nanosleep()
doesn't take a struct timespec and internally resumes onEINTR
), but our divergence is here is perhaps a bit heavier.