I discovered this technique awhile back when I was still getting into Zig. In retrospect, I would try to avoid using it except for very simple cases. Without going into the more technical issues, it just seems out of place. It’s almost like you are trying to use Zig as a scripting language. So I would imagine in most cases there would be a better way to deal with it.
2 Likes
To deal with what?
To handle multiple calls of the same method. Instead of chaining them together with dot syntax, I would say more often than not there will probably a better solution. I am talking about in general. Especially if you are getting into issues with the compiler, it might be hard to tell where the problem is coming from in larger programs…
In your case specifically, for the first example you posted, I’m not sure exactly what I would do differently. You are basically trying to chain mathematical expressions using the dot syntax. I am thinking you could use an enum to indicate which function you need to call, and switch over that, for however many mathematical operations you need to carry out.