5 ms·
Using parens to pass type arguments was one of the things that turned me off on Zig. For a language that prioritizes "no hidden control flow," it sure did a lot
by ninepoints 2y ago
Using parens to pass type arguments was one of the things that turned me off on Zig. For a language that prioritizes "no hidden control flow," it sure did a lot to make various syntax conventions _masquerade_ as control flow instead.
- codethief 2y agoWhat do you mean? It is control flow. Generic functions are just higher-order functions that get evaluated at compile time.
- cobbal 2y agoIt is an interesting question of definitions. Is control flow only at runtime? Is `#if` control flow in C? If I had to define it, I would go with runtime-only, but I could see the other way too.
- superb_dev 2y agoZig’s comptime is just code that runs at compile time. Unless we have another term, we must call it control flow
- strogonoff 2y agoMacros can have control flow, so compile-time control flow is definitely possible, but perhaps we trained ourselves to not think of control flow in this way because using complicated compile-time logic is generally frowned upon as a footgun. Perhaps Zig is the language that on purpose blurs the line between what runs when (by basically having what looks like macros integrated into runtime code without any conspicuous hashtaggy syntax), and so a Ziggy would not see compile-time control flow as something weird.
- ninepoints 2y ago[flagged]
- hu3 2y agoI don't get it. Their reply looks normal to me. Is it because they disagree with you? I take these instances as learning opportunities and that makes me want to comment more, not less.
- deleted 2y ago[deleted]
- flohofwoe 2y ago> Using parens to pass type arguments was one of the things that turned me off on Zig. It's just regular comptime function calls which happen to have parameters or return values which are comptime type values (types are comptime values in Zig). I find that a lot more elegant then inventing a separate syntax for generics, and it lets you do things trivially which are complex in other languages (like incrementally building complex types with regular Zig code). It might be unusual when coming from C++, Rust or Typescript, but it feels 'natural' pretty much immediately after writing a few lines of generic code.
- NotACracker 2y agoLike what?