Re: [PHP-DEV] Re: Clarification on the Enum language structure

2011-02-18 Thread Ben Schmidt
class Grade { enum { A_PLUS, A, B_PLUS, B, ..., FAIL, NOT_AVAILABLE, } public static function passing($grade) { return $grade>=self::D; } } $grade=Grade::B; echo Grade::passing($grade)?"passing":"not passing"; Shouldn't that be: public static function passing($grade) { -return $grade>=self::D;

Re: [PHP-DEV] Re: Clarification on the Enum language structure

2011-02-18 Thread Ben Schmidt
On 19/02/11 5:37 AM, Martin Scotta wrote: Enums are a new "type", they are different to any existent type.(if not, what is the point of creating them) It seems to me, however, that what you are suggesting makes them almost the same as classes, and I don't really think there is any point in doi

Re: [PHP-DEV] Re: Clarification on the Enum language structure

2011-02-18 Thread Rick Widmer
On 2/18/2011 9:28 PM, Ben Schmidt wrote: I did some research on methods in enums and discovered that there is some usefulness to the idea - I wouldn't go so far as to say that they would be needed, but C#, for example, allows you to create extension methods for enums and MSDN has a decent real-wo

Re: [PHP-DEV] Re: Clarification on the Enum language structure

2011-02-18 Thread Ben Schmidt
I did some research on methods in enums and discovered that there is some usefulness to the idea - I wouldn't go so far as to say that they would be needed, but C#, for example, allows you to create extension methods for enums and MSDN has a decent real-world example of its use. http://msdn.micro

Re: [PHP-DEV] Re: Clarification on the Enum language structure

2011-02-18 Thread Stas Malyshev
Hi! I should comment on why people want strings as enum values - just look at ENUM type in MySQL. People use it, and if you take a look from that perspective - it makes sense. Enum type in the database is totally different because it's a constraint, not an alias to some underlying piece of da

Re: [PHP-DEV] Re: Clarification on the Enum language structure

2011-02-18 Thread Martin Scotta
Enums are a new "type", they are different to any existent type.(if not, what is the point of creating them) Everybody agree that an enum is a set, in the mathematically point of view, of names and values. What we are discussing here is what should be those "values". IMO that should be a programm

Re: [PHP-DEV] Re: Clarification on the Enum language structure

2011-02-18 Thread Hannes Landeholm
Let me jump in here and say that I agree that strings are useful. IMO any scalar type should be allowed for enum's. String enum's are great for understanding debug data. Also it would integrate smoothly with MySQL enums (building queries) and when you want to model enumerations in an external API o

Re: [PHP-DEV] Re: Clarification on the Enum language structure

2011-02-18 Thread Arvids Godjuks
Hello! I should comment on why people want strings as enum values - just look at ENUM type in MySQL. People use it, and if you take a look from that perspective - it makes sense. But we are not a MySQL only world, so it does not make sense to do strings, because in other databases usually 1 byte

RE: [PHP-DEV] Re: Clarification on the Enum language structure

2011-02-18 Thread Jarrod Nettles
I did some research on methods in enums and discovered that there is some usefulness to the idea - I wouldn't go so far as to say that they would be needed, but C#, for example, allows you to create extension methods for enums and MSDN has a decent real-world example of its use. http://msdn.mic