For Programmers: Free Programming Magazines  


Home > Archive > PHP Zend Engine > November 2005 > RE: [ZEND-ENGINE-CVS] cvs: ZendEngine2(PHP_5_1) /zend_compile.c









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: [ZEND-ENGINE-CVS] cvs: ZendEngine2(PHP_5_1) /zend_compile.c
Stanislav Malyshev

2005-11-19, 3:55 am

AG>>> Compiler allowed (array $a = null), but executor emited error.
AG>>
AG>>Maybe we should fix the compiler?

Yes, I think too that compiler can catch this and output an error. Though
I don't think if it does not it's a bug - after all, compiler is not
supposed to check argument types, it is supposed to check only sytax
correctness.

--
Stanislav Malyshev, Zend Products Engineer
stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115
Antony Dovgal

2005-11-19, 7:55 am

On 19.11.2005 10:21, Stanislav Malyshev wrote:
> SM>>Yes, I think too that compiler can catch this and output an error. Though
>
> On the second thought - if we don't write a default, is null allowed to
> places typehinted as array? If not, we should keep both things consistent.
> I.e., if we allow it as default, we should allow it in typehint too. This,
> however, may lead to some surprises. I know Java allows nulls to represent
> any type - should we do the same?


I think yes, NULL should be able to represent "nothing of any type".
That makes it consistent and that's what I would expect.

--
Wbr,
Antony Dovgal
Antony Dovgal

2005-11-19, 7:55 am

On 19.11.2005 14:20, Stanislav Malyshev wrote:
> AD>>I think yes, NULL should be able to represent "nothing of any type".
> AD>>That makes it consistent and that's what I would expect.
>
> Would you expect to get a warning when you pass variable that is
> typehinted as array to, for example, join()?
> Would you expect a warning if you pass null there?


No, I wouldn't expect to get a warning from a function which uses array() for typehinting.
NULL is just "nothing", if a function were expecting an array and got nothing - fine, we got nothing as the result either.

--
Wbr,
Antony Dovgal
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com