October 31

On Saturday, 26 October 2024 at 08:28:43 UTC, Kagamin wrote:

>

Indeed why not use manifest constants?

Read the existing discussion.

October 31

On Saturday, 30 March 2024 at 14:57:00 UTC, IchorDev wrote:

>

To declare an enum type that may or may not have one or more members depending on conditional compilation statements requires duplicating the entire enum:

static if(cond){
	enum A{
		x,y,z,w,
	}
}else{
	enum A{
		x,y,z,
	}
}

For an enum type with many members—or many conditionals—this quickly becomes an insane amount of repetition.

The logical solution is to just allow conditional compilation statements inside enums:

enum A{
	x,y,z,
    static if(cond){
		w,
	}
}

Yesterday I was thinking to add that feature to another language (understand "one where there's no implication", you can experiment and "nobody will loose money") and realized a problem that's not been raised before:

That would make the grammar significantly more complex. For now the body of a "EnumDeclaration" can only contain "EnumMembers", whereas if you permit "StaticIfDecl" or "VersionDecl" then you also have to special case those in order to be sure that they can only contain EnumMembers.

1 2 3
Next ›   Last »