4 ms·
don't know about the language rules, but I've had to wait for the explanation to understand what was about to happen. Naming is hard, d'oh, but I feel this coul
by ephaeton 4y ago
don't know about the language rules, but I've had to wait for the explanation to understand what was about to happen. Naming is hard, d'oh, but I feel this could have a better name. "inline" does not trigger my brain in a way a "comptime_expanded" or "comptime_generator" would, e.g.
I believe andrew and loris have been with zig for long enough to have their own bias and no longer be aware of it, thus I believe it's the newcomers' job to hold up the simplicity design premise now...
- kristoff_it 4y ago"inline" constructs all behave kinda the same way in Zig, like I've explained in the article. Once you're used `inline for` etc, it all works in a fairly homogeneous way. This article was mostly about pointing out how `inline else` lends itself really well to writing tagged union interfaces, I would expect anybody who actively writes Zig and has metaprogramming experience to not have much trouble using it.
- ephaeton 4y agoThat's what I mean with you having developed a bias and no longer being aware of it [no insult intended] ;) If you know the concept in that language and its name-tag, then it's no longer confusing, just as lisp macros aren't anymore once you grokked them. As a language in development, I would hope the on-boarding process from people with a different background would be designed to be as smooth as possible. IMO, someone coming from a different, popular systems programming language will probably have quite a different expectation what "inline" means - I know I do. Maybe finding an alias/new name for "inline" here can be considered before a "1.0".
- kristoff_it 4y agoSure, I don't mean to claim that what inline does is self-evident. This article was really meant for people in the Zig community and in some sense it's unfortunate it reached the front page of HN. > Maybe finding an alias/new name for "inline" here can be considered before a "1.0". I would be on board with that, yes.
- stephc_int13 4y agoThe Zig syntax has been drifting for some time and it is not in a good place. I am afraid that the designers are blind to it because they are using it every day. I am also afraid that once a lot of code and libraries are written, it will be difficult / impossible to change the syntax, it might already be too late. I love Zig but the syntax quirks might considerably slow its adoption.
- int_19h 4y agoI don't think this is Zig-specific terminology, though. For example, F# has something similar for functions: https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/inline-functions https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...
- larsnystrom 4y agoWhy isn’t the compiler just doing inline whenever possible? Why is it a user-facing feature of the language, it looks like it should be a compiler optimization to me.
- kristoff_it 4y agoInlining (in the C/C++ sense of the term) is not always preferable. On top of that, in this specific case, `inline` has a Zig-specific meaning that pertains to generics and metaprogramming in a way that has not much to do with the C/C++ use of the term.
- anonymoushn 4y agoThe programmer might know more than the compiler about which things should be expanded at compile time and which things should not. Zig is intended to be able to be used to generate optimal code.
- audunw 4y agoBut "inline" is routinely used in C in "inline functions".. I don't think anyone with a decent amount of experience with C would have trouble quickly seeing what inline means in Zig, and those people are the primary target audience for Zig. It's short and concise IMO.
- AnIdiotOnTheNet 4y agoMakes enough sense to me, although I was using Zig years ago. An inlined function is a function that is not called in the traditional sense and instead its effects are replicated as though the function code had been written at the call site. With `inline for` and `inline while`, the for loop isn't run in the traditional sense and instead is unrolled as though each instance of the loop had been written separately. With `inline else`, every possible instance not covered by a `case` is expanded as though it had been written separately. It's a little weird to C programmers only because C doesn't expand the concept outside of functions.
- krona 4y agoI have a lot of experience with C/C++ and I don't understand what this really has to do with inline expansion or linkage behaviour.
- stephc_int13 4y agoInline has a different meaning in C/C++, and to be honest it was not a very good keyword choice in the first place.
- frou_dh 4y ago> I believe andrew and loris have been with zig for long enough to have their own bias and no longer be aware of it, thus I believe it's the newcomers' job to hold up the simplicity design premise now... Zig aside, that's an astute observation in general. I think this is an issue in Python where the old guard that have been part of the project for decades and are extreme experts have gotten bored and started cramming in new language features.