Re: Passing anonymous enums as function parameters

2017-12-20 Thread kerdemdemir via Digitalmars-d-learn
enum { a = "foo", b = "bar", c = "baz"; } is identical to enum a = "foo"; enum b = "bar"; enum c = "baz"; Thanks Jonathan I think that changes my point of perspective. And Jacob Carlborg I like the third option a lot with aliases good to know that enum Foo : string { KErde

Re: Passing anonymous enums as function parameters

2017-12-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-17 20:45, Jonathan M Davis wrote: That's pretty much just declaring manifest constants with braces so that you don't repeat the keyword enum a bunch of times. Anonymous enum is what the spec calls it and was available before manifest constants. -- /Jacob Carlborg

Re: Passing anonymous enums as function parameters

2017-12-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, December 17, 2017 12:47:26 kerdemdemir via Digitalmars-d-learn wrote: > What I meant with anonymous enums was: > https://dlang.org/spec/enum.html#anonymous_enums. Maybe I > couldn't explain well but I believe D have anonymous enums. I am > sorry I have forgotten to remove " :string" in

Re: Passing anonymous enums as function parameters

2017-12-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-17 12:49, kerdemdemir wrote: I have an enum statement : enum : string {     KErdem     Ali     Zafer     Salih     //etc... } I don't want to give a name to my enum class since I am accessing this variables very often. But I also have a function like: double ReturnCoolNess(

Re: Passing anonymous enums as function parameters

2017-12-17 Thread kerdemdemir via Digitalmars-d-learn
What I meant with anonymous enums was: https://dlang.org/spec/enum.html#anonymous_enums. Maybe I couldn't explain well but I believe D have anonymous enums. I am sorry I have forgotten to remove " :string" in my example from the "enum : string". Please stretch out ": string" part my problem is

Re: Passing anonymous enums as function parameters

2017-12-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, December 17, 2017 11:49:58 kerdemdemir via Digitalmars-d-learn wrote: > I have an enum statement : > > enum : string > { > KErdem > Ali > Zafer > Salih > //etc... > } > > > I don't want to give a name to my enum class since I am accessing > this variables very o

Passing anonymous enums as function parameters

2017-12-17 Thread kerdemdemir via Digitalmars-d-learn
I have an enum statement : enum : string { KErdem Ali Zafer Salih //etc... } I don't want to give a name to my enum class since I am accessing this variables very often. But I also have a function like: double ReturnCoolNess( /* Is there any way? */ enumVal ) { switch