Re: Re: Clarification on the Enum language structure
| From: | Alexey Zakhlestin | Date: | Thu, 24 Feb 2011 07:31:13 +0000 |
| Subject: | Re: Re: Clarification on the Enum language structure | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51530@lists.php.net to get a copy of this message | ||
On Thu, Feb 24, 2011 at 5:00 AM, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
> Hi!
>
>> You can do it like this. When an enum is defined:
>
> I'm not talking about implementation in the code of PHP engine. I'm talking
> about writing code with these things that wouldn't produce fatal errors in
> random places without you being able to prevent it and without checking
> before each function call. Compiled languages deal with it easily because
> they check these things on compile - if you try to send int variable where
> BlahBlah type is expected, the compiler bails out and you know it's a
> problem. Dynamic languages don't work that way.
except, that it could be handled by "thow new InvalidArgumentException()"
but we don't allow exceptions in core
--
Alexey Zakhlestin, http://twitter.com/jimi_dini
http://www.milkfarmsoft.com/