1

I'm reading about Swift enum's in the Swift Programming Language guide and the text was comparing the differences between Swift's enum and C's enum. This made me curious as to where enumerations came from originally. I did search online before asking and even asked a few people and they assumed C. (I suppose I'm trying to confirm if enumerations came from C originally.)

What was the first programming language to include enumerations?

8

Probably Lisp (1958).

In Lisp dialects, symbols can be used in the same way as C's enumerations. Indeed, the Wikipedia page for Symbol (Programming) says:

In the most trivial implementation, [symbols] are essentially named integers (e.g. the enumerated type in C).

Scheme and Common Lisp have a member function, which can be used like:

(member 'b '(a b c))
;=> (b c)

Fortran also has an enumeration type, but it looks like it was added in Fortran2003 for compatibility with C's enum, which itself was only added in ANSI C (1989).

  • 1
    In particular, you can define an enumerated type: (deftype bool () '(member true false file-not-found)) (ref. TheDailyWTF). That can be used to check the type of your values with typep. – coredump Oct 7 '15 at 16:49
-1

In the strict sense, the answer is probably Pascal. Pascal certainly had enumerated types before C did. Algol 60, Algol W, Burroughs Algol, Simula 67, and Algol 68, Pascal's more noteworthy predecessors, did not. In a somewhat weaker sense, COBOL "88-level" definitions are not completely utterly and entirely unlike enumerations; you could say that the germ of the idea was there (more than in Lisp).

  • 2
    Can you edit in some references to back up your statement? – Jan Doggen Feb 26 '16 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.