Many languages seem to have structures that are very similar called iterable or enumerable. These are structures that can be iterated or enumerated over, which seem to me extremely similar things. Are these words synonymous or is there a subtle semantic difference between iterable and enumerable which justifies the choice of term?
IMHO this depends on the context, sometimes they are synonymous, sometimes they are not. For example, in C# you have a data type "IEnumerable", which classifies iterators, but you have also the "enum" declaration which is for symbolic constants, not specificially for iterations. In other programming languages (or other contexts) the situation may be similar or not.
If you mean the two words just as english verbs and not specifically as programming language keywords, then
- iterating means to "loop over all elements of a set, one by one"
- enumerating means to "give each element of a set an ordinal number, one by one"
And since iterating is needed for enumerating, and enumerating implies some kind of iteration, those two process descriptions can typically be interchanged.
As others have said, the precise semantics depend on the programming language that uses the terms, so I'll give a purely linguistic appraisal.
"Iterable" is a rather new-coined word, obviously referring to "iterating" and the "iterators" that many languages have built in. Therefore, such types almost certainly support an iterator, but not necessarily anything else, and not necessarily anything beyond the most basic iterator functionality: processing every item once. Reversing, deleting, measuring distances etc. may or may not be supported.
"Enumerable" refers to enumerating things, which can mean the same as iterating, but only if the language doesn't already use "iterable" for that purpose. If a language has both, "enumerable" almost certainly means something else, probably something more powerful. Most likely, it will support the notion of connecting each element with a unique numeric index, and probably it will allow random access (e.g. retrieving the third element before the first and second ones).
That's about all the meaning you can reasonably infer from just the words. In any concrete situation, refer to the standard library API docs.
I want to focus on the strict definition of both terms
Iterable is to iterate things, and get access to the element one by one.
I think that the term
Enumerable was originated from the turning machine. It's about the ability to list out the element one by one in a proper order. The things can be listed out one by one has to be
countable, each one has a unique correspondence index. Given an element, you can get a unique index. Given an index, you can only find one possible element associated with that index.
In other words,
Enumerable implies the ability to generate the elements . Some programming language, for example,
Haskell has implemented this idea. There is a Enum type class, and
Char is one the instance.
Prelude> fromEnum True
Prelude> fromEnum False
Prelude> toEnum 1 :: Bool
Prelude> fromEnum 'a'
Prelude> enumFromTo 'a' (toEnum 122 :: Char)