Re: Constant and expression ?
| From: | Stas Malyshev | Date: | Fri, 21 May 2010 18:12:18 +0000 |
| Subject: | Re: Constant and expression ? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48378@lists.php.net to get a copy of this message | ||
Hi!
I agree that enum make more sense when it's a type but I disagree with the fact that it make code less understandable. The goal of this patch is to make it easy to create a list of constants when the value is not necessarily important (For example when you create a lexer you don't mind if the integer value of your token is 300 or 400 as soon as it's a unique value and that you can use the name of this token to do your comparison) and the only thing you want is to assign a unique value within your enumeration.Creating lexers isn't really a common thing for PHP (and shouldn't be). And you probably wouldn't produce the list of 400 tokens manually, at which point you could as well generate their values too. But if you have not that many - like 3-4 in your examples - I think it's better not to be lazy and put the values in. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227