enum behaivor. another rehash of the topic
Maxim Fomin
maxim at maxim-fomin.ru
Sun Dec 15 10:30:38 PST 2013
On Sunday, 15 December 2013 at 11:27:51 UTC, bearophile wrote:
> By the way, I am not criticizing "D verbose approach". I have
> criticized the weak typing:
>
>
> enum Foo { good, bad }
> void main() {
> int x = Foo.good; // Weak typing.
> }
>
This is not a weak typing. An example of weak typing is array
literal [].
There is nothing wrong with converting enum to base type, since
enum is always subset of base type. Explicit cast in such case is
useless. What is your point against current behavior?
> And some people have criticized the verbosity in special
> situations, like this:
>
>
> enum Foo { good, bad }
> void bar(Foo f) {}
> void main() {
> // bar(bad); // Not enough
> bar(Foo.bad);
> }
>
> Bye,
> bearophile
because 'bad' is undefined identifier, but I see your point.
More information about the Digitalmars-d
mailing list