4 ms·
Most "stringly-typed" systems seem inherently quirky to me. In something like Javascript, everything else is so loose, it's like why not use strings, but I've a
by dougk16 13y ago
Most "stringly-typed" systems seem inherently quirky to me. In something like Javascript, everything else is so loose, it's like why not use strings, but I've always wondered why things like HTTP headers couldn't be handled using enums. I think it would cover a lot of the cases mentioned in the article without having a weird-at-first-glance abstract string paradigm to deal with.
As a practical matter, I think enums couldn't be used in the Java spec because it was written before enums were available in the language. Enums also suffer from extensibility issues, but that could be solved by having stringly-typed overrides. I've also been contemplating the possible merits of extensible enums for solving issues like this. So for example you could have an enum type that extends the HttpHeader enum. The ordinality would be weird if there were multiple sub-enums, but it might not matter for most practical cases. I can think of a few language-level ways to deal with the ordinality issue too.