On Wed, Feb 5, 2014 at 6:47 AM, Andrea Faulds <[email protected]> wrote:
> On 04/02/14 21:30, Yasuo Ohgaki wrote:
>
>> eval() works.
>>
>> php > assert(eval('FALSE;'));
>>
>> Warning: assert(): Assertion failed in php shell code on line 1
>> php > assert(eval('return FALSE;'));
>>
>> Warning: assert(): Assertion failed in php shell code on line 1
>> php >
>>
>> However, it does not solve inconsistency. PHP code has to be string.
>> Writing PHP code as string is not fun thing to do ;)
>>
>
> That's not what I meant. At present, you do:
>
> assert($string);
>
> And that string is evaluated. A closure would be faster. Though this is
> for debugging code, so I'm not sure it matters (though I, unlike some
> people, might like to use assertions in production code to make sure things
> fail early, fail often).
I think I understood your comment.
php > assert('function() {return FALSE;}');
php > assert('function() {return TRUE;}');
It does not work, but
php > assert(eval('function() {return FALSE;};'));
Warning: assert(): Assertion failed in php shell code on line 1
so closure in eval() works. I don't see reason not to allow closure
directly.
It only seems inconsistent to me.
Regards,
--
Yasuo Ohgaki
[email protected]