Enum class

Lennart Augustsson lennart@augustsson.net
Tue, 23 Oct 2001 19:33:59 +0200

"Ch. A. Herrmann" wrote:

> >>>>> "Lennart" == Lennart Augustsson <lennart@augustsson.net> writes:
>     Lennart> "Ch. A. Herrmann" wrote:
>     >> (1) What is the justification for the types "Float" and "Double"
>     >> to be members of the type class "Enum"? This might induce
>     >> students to use floating point values as counters in arithmetic
>     >> sequences.
>     Lennart> And what's wrong with that? If the students are using are
>     Lennart> using values like 0.1 and expecting it to be represented
>     Lennart> exactly then they should have some lectures about floating
>     Lennart> point arithmetic.
> The point is that students might use the fact that Float and Double are
> in type class Enum as a justification to use it in practice, e.g.,
> to avoid an Int->Float conversion.

What I was trying to say is that if you are using floating point numbers you
should have some clue what you are doing.  This goes for doing conversions
Int->Float (a suspicious operation since you might loose precision) or using
an operation in Enum.  As I said, floating point types are very complicated
and should not be used without some knowledge if you care about the result.
(Rational and Integer, on the other hand, are very well behaved types.)

> Removing them would possibly cause problems with existing programs
> and this is definitely not my aim. However, it'll make sense to
> think about long-term improvements. I wouldn't call Float and Double
> enumeration types. Maybe, a just misunderstood what Enum means.

Yes, Enum is a bad name.

    -- Lennart