Follow

C has a lot of problems but it also has designated initializers, so it's impossible to say if it's bad or not,

I realise the only way C can have this feature in the first place is because of it's odd initialization semantics (particularly zero initialization, which only works by virtue of not having constructors (and thus having all types be trivially constructable)

Rust probably couldn't do this. C++ couldn't do it for the longest time, and it only got reintroduced in heavily nerfed form

I guess Rust could do it using the Default trait but that wouldn't work in a static/const context because const trait stuff is still WIP? Either way Rust probably would still choose not to have this, since it'd be syntactically awkward and probably unintuitive.

Anyway I think this feature kicks ass and C99 is despite its flaws still a pretty fun language to write in. sue me

@saphie (Found this quite late, but...) I was gonna ask "can't const_fns do this in Rust?", but now that I think about it... I guess array initialization wouldn't count as a const_fn...

@saphie what, even, does that do?, i ask, instead of looking up what designated initializers are

Sign in to participate in the conversation
monads.online

monads.online is a place for friends