logoalt Hacker News

sesmtoday at 11:11 AM2 repliesview on HN

Instead of implementing a workaround for types as namespaces, wouldn't it better to explicitly add namespaces to the language?


Replies

txdvtoday at 2:07 PM

I think zig is striving for language minimalism, make it minimal as possible then if a feature optimized multiple places use cases benefit

Arch485today at 1:23 PM

It's not so much a workaround as it is an elegance in design. In Zig, when you @import a file, that file is converted to a struct with comptime fields for all of the public members. Similarly, a "namespace" in Zig is just a nested struct with more fields. Usually it's just another import of something else.

N.B.: Coffee hasn't reached my bloodstream yet; accuracy not guaranteed.