4 ms·
An enum with no cases works pretty well as a namespace.
by mikeash 9y ago
An enum with no cases works pretty well as a namespace.
- PopsiclePete 9y agoI mean, sure, there are work-arounds I guess. Still weird to rely on work-arounds like this. Also, there are at least 4 different workarounds to this, so imagine working on a large code base where everyone has their preferred approach is...fun. Or it would have been fun in '98 or so, nowadays, for a brand new language - it's just sad.
- mikeash 9y agoI can think of three: enum, class, and struct. What’s the fourth? And what’s the big deal if you encounter some code that uses a different one?
- bsaul 9y agoWhy can't we have just one way of declaring and naming namespaces using something called... namespaces ? There are probably goos reasons for doing it this way, but it always feels weird having to declare all your namespace's types inside one of its member.
- mikeash 9y agoIf you allow nesting things inside types, then those act as namespaces, so you’ll always have multiple ways even if one of those ways is explicitly called “namespace.” I agree the language should have it, but it doesn’t seem like a particularly big deal.
- dahauns 9y agoUrgh. Why do stuff like this on a newly designed language? I mean, that sounds like javascript from ten years ago, and I didn't think anyone would like to go back there.