On 17 February 2011 19:32, Martin Scotta <martinsco...@gmail.com> wrote:
> On Thu, Feb 17, 2011 at 3:01 PM, Jarrod Nettles <jnett...@inccrra.org>wrote:
>
>> An enum is not a class.
>
> totally agree. an enum is a family of related constant values.
>
>
>> It has no methods or properties and is not something that you instantiate.
>>
> partially agree, you cannot instantiate nor destruct a constant.
> it's a value that does not change over time, but why can't it be an
> immutable object?
>
>
>>
>> Also, I feel like it should be restricted to integral types only, and
>> defaults to a zero-based incrementing integer. This is more in line with
>> other programming languages that already implement enums and will present
>> "expected behavior" for people moving over to PHP.
>>
> for me that's a plain old interpretation of constants.
> constant values were only integer values because of their implementation,
> nowadays they could be anything you want, int, float, string and even
> objects.
>
> enum MyEnum {
>      A, B, C;
>      function test() { return true; }
> }
>
> $value = MyEnum:B;
>
> if ( $value->test() ) {
>    echo ' what is wrong with this ? ';
> }

That looks like a mix of an enum and a struct.

Can you provide any realworld examples where an enum contains anything
other than integers?

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to