|
|
|
|
|
by dnautics
1995 days ago
|
|
That not an empty struct, rather an empty anonymous array. It's there because zig doesn't have overloaded function params. Print must take two arguments. The || syntax is used elsewhere in zig, if statements, catch, switch, etc. There's no requirement for a function inside a struct to act on the contents of structs, so it's reasonable to use structs as namespaces. This is what is happening when you @import, for example. The imported file becomes a struct. This is quite different from a lot of other PLs, but it is pleasantly consistent when you get used to it. There is a usingnamespace keyword to make a structs public contents spill out into the current scope. It's to be used sparingly. Edit: I'm wrong! It's an anonymous struct with number fields, not an anonymous array. |
|
also why ask for a parameter when it is not needed? print vs printf in C