3 ms·
C uses pointer casts all over the place to fake generics. If you don't have that (in Pascal or MODULA-2) then life becomes very unpleasant. There is a quite a
by phicoh 8mo ago
C uses pointer casts all over the place to fake generics. If you don't have that (in Pascal or MODULA-2) then life becomes very unpleasant.
There is a quite a bit of C code that makes creative use of the size of allocations. For example linked lists with a variable sized payload. Again one of the things that would prevent a C programmer from switching to Pascal.
I don't expect the Zig user base to become larger than the Rust user base any time soon. But we have to wait and see, Zig is quite young.
- pjmlp 8mo agoSame tricks are possible in Modula-2, Pascal, Ada, if fake generics count. Creative use of the size of allocations are also possible in those languages, the BIG difference is that they aren't the default way everything gets done.
- thezipcreator 8mo ago> C uses pointer casts all over the place to fake generics. by "C" do you mean users of C? because most of the C code I write I don't use those sorts of techniques; instead I just use the preprocessor to make scuffed generics.[1] Unless you mean in libc itself, where I don't recall any use of pointer casts like that? If I'm missing something, please enlighten me. [1] see my (probably terrible) dynamic array implementation, for example: https://git.sr.ht/~thezipcreator/xstd/tree/main/item/src/xstd/container/sequence.h https://git.sr.ht/~thezipcreator/xstd/tree/main/item/src/xst...