3 ms·
> Will I need to declare "Self"? If so, will be "Self" part of the struct's memory layout? I'm only familiar with C++, not Zig, but it doesn't seem that differ
by quietbritishjim 4y ago
> Will I need to declare "Self"? If so, will be "Self" part of the struct's memory layout?
I'm only familiar with C++, not Zig, but it doesn't seem that different to me. If a C++ class includes a typedef, then that doesn't contribute to the class's footprint.
Even the explicit self parameter is not so different. In C++, a method can be marked as const or even && (rvalue reference) and that's applied to the implicit this parameter. If anything, it would be clearer if this was an explicit parameter; as of C++23, it actually is allowed to be [1], called "deducing this".
[1] https://devblogs.microsoft.com/cppblog/cpp23-deducing-this/ https://devblogs.microsoft.com/cppblog/cpp23-deducing-this/