#30 Add Enum type to language.

closed
nobody
None
5
2009-10-02
2009-08-12
No

Having an ability to define new types with

enum e_type { a=0, b, c, d };

which I could use in function defenitions

void bar(int x=0, enum e_type y) { if (y==a){return x;} else {return 0;} }

would be great. Currently I do

int a=0, b=1, c=2, d=3;

but that clutters the namespace, and makes function arguments more ambiguous, requiring

bar(x=a);

rather than just

bar(a);

Discussion

  • John Bowman

    John Bowman - 2009-10-02

    There's no need for an enum keyword; follow the interaction example in three_surface.asy instead:

    struct interaction
    {
    int type;
    void operator init(int type) {
    this.type=type;
    }
    }

    restricted interaction Embedded=interaction(0);
    restricted interaction Billboard=interaction(1);

     
  • John Bowman

    John Bowman - 2009-10-02
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks