mfichman / jogo

High(er) performance compiled programming language with clean, powerful syntax
MIT License
6 stars 1 forks source link

Enums and Constants #41

Closed mfichman closed 12 years ago

mfichman commented 12 years ago

Add enums, which are basically implemented as a set of integers inside a class scope. For example:

CarState < Enum {
    ON
    BROKEN
    OFF
}

Another alternative syntax is:

CarState = ON | BROKEN | OFF 

Similarly, union types have a similar syntax:

JsonValue = String | Int | Float

Or:

JsonValue < Union {
    String
    Int
    Float
}
mfichman commented 12 years ago

Closed, except for an unrelated issue: Auto-importing is now ambiguous, because A::B::symbol could be from a module named "A::B" or from a class named "B" in module "A". To resolve, each module in the path will have to be tried for import separately, starting with A::B::C; and if that fails, A::B; and if that fails, A.