lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, 12 Nov 2009, Stephen Kellett wrote:
>
> They seem proud of not having enumerations. I'd have thought the dreadful
> mistake of omitting them from Java (which has now added them back into the
> language) had been learned by now. "iota" seems to be a passing nod to the
> concept of monotonically increasing values (which is how most enums, but not
> all, work). But integers are not a typesafe substitute for enums. Perhaps I've
> missed something about Go and enumerations (I was tired when reading about it)
> but I think that is something that needs addressing. If I've got that wrong,
> someone please correct me.

You can declare the type of a (set of) constant(s) making it safe since
there's no implicit conversion (even if the type is just an alias). See
for example the ByteSize enum defined at
http://golang.org/doc/effective_go.html#constants

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.