Reply to Re: bug or feature? (OO design/languages)

Your name:

Reply:


Posted by raf on 09/17/05 13:57

www.douglassdavis.com wrote:
> All three of the following classes give "compile-time" errors. It
> hinders me from doing what I want to do... And it seems there is no way
> around it. But, are each of these cases examples of how the language
> should behave? Are any of the examples a case of PHP being
> "incorrect?"

I don't know PHP, but I believe these are bugs in your code:


> class MyClass
> {
> static $x = 2;
> static $y = self::$x; // error
> }

there is no instantiation of the class--there is no "self" object.
Did you mean "static $y = $x"?

> class MyClass2
> {
> var $x = 2;
> static $y = $x; // error
> }

In this case, since no object was created, there is no $x to assign into
$y.

> class MyClass3
> {
> const a = array(1,2); // error
> }

I defer this to someone who knows PHP, but if its semantics are
comparable to Java and C#, does "array(1,2)" actually create an instance
of an array? Based on the pattern of the errors above, I'd suggest you
review the concepts of object instantiation and class/instance member
variables.

raf

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация