🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c++
Article #206

Unintuitive semantics for enum

#206
From: David Sher
Date: Sat, 24 May 1986 21:12
38 lines
1661 bytes
I just tripped over another "feature" of c++.
This feature is that enums are not types.  
They look like types but really are synonomous with sets of 
constant definitions and typedefs of ints.  This strikes me as wrong.
Consider this c++ file:
enum footype { FOO = 17 };
void bar ( footype g );
void foo ( footype f )
    {
	bar ( 13 );
    }

overload baz;
void baz ( footype h );
void baz ( int i );

class myclass
    {
    int k;
public:
    myclass ( footype f );
    myclass ( int i );
    ~myclass ( ) { ; }
    };

First I think it is wrong that c++ accepts the statement 
bar ( 13 )
as good.  If bar takes footype's it should not take arbitrary
integers.  Note also that the compiler accepts the definition of baz
but refuses the constructor definition of the class.  This seems very
odd because either both baz and myclass is ambiguous or both are
unambiguous so the compiler should accept both or reject both.  
I know the language is defined this way but the compiler should at
least give warnings when "type violations" of this sort occur.
-- 
-David Sher
sher@rochester
seismo!rochester!sher
Technical Details
Message-ID: <18407@rochester.ARPA>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!gatech!seismo!rochester!sher

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!gatech!seismo!rochester!sher
From: sher@rochester.ARPA (David Sher)
Newsgroups: net.lang.c++
Subject: Unintuitive semantics for enum
Message-ID: <18407@rochester.ARPA>
Date: Sat, 24-May-86 17:12:11 EDT
Article-I.D.: rocheste.18407
Posted: Sat May 24 17:12:11 1986
Date-Received: Sun, 25-May-86 16:03:43 EDT
Reply-To: sher@rochester.UUCP (David Sher)
Organization: U of Rochester, CS Dept
Lines: 38
Keywords: enum