Inheritance of Static Properties
Seriously, PHP, it's not that hard...
Python (right):class A:
spam = 'eggs'
class B(A):
pass
B.spam = 'meat'
print A.spam # prints "eggs"
PHP (wrong):class A {
public static $spam = 'eggs';
}
class B extends A {
}
B::$spam = 'meat';
echo A::$spam; // prints "meat"
Sigh.
Posted by Luke at 1:02 p.m.
The issue here is broader than inheritance, but down to the different variable models of Python and PHP.
In Python, everything is an object that can have any number of variables that refer to it, and assignment can never change anything about the variable, which is merely a label that can be moved around at your whim.
I am less familiar with PHP's semantics, but I understand that it has a more traditional variable model, such that $foo is really something and that you can have its value or references to it. (In Python, there are only references everywhere, really.) For PHP to support what you want, it would have to copy all the stuff in A when you make it, which might be a whole lot of stuff and not what you want much of the time as well.
There are many parts of PHP I would say are awful ideas, but these semantics for variables seem as legitimate to me as Python's way of doing it. Working within that system, this response makes more sense to me than copying everything, though this effect is evil (and screams never-change-anything-you-inherited, I suppose). Perhaps I'm missing some aspect of PHP that makes your desired behavior possible as something consistent with the rest of PHP.
Also, inherit your classes from object.
Posted by Mike on 2009.09.13 at 11:11 p.m.
混合机混合器乳化机搅拌机分散机过滤器阻火器给料阀
视镜
Posted by cxzf on 2009.10.17 at 8:58 a.m.
restaurant equipmentskitchen equipments
catering equipmentprofessional kitchen
food service equipmentrestaurant appliance
food display cabinets
Refrigerated display
commercial pizza oven
Commercial Ovens
restaurant oven
commercial refrigerator
Restaurant Refrigerators
professional freezer
stainless steel refrigerators
commercial cooking equipment
Restaurant Griddles
Restaurant Fryers
pizza restaurant equipment
Pizza Prep Tables
Posted by dd on 2009.10.17 at 10:23 a.m.
injection moldingplastic injection Chinaplastic injection moldChinese AcrylicAcrylic in Chinaplastic moldsplastic moulds
sand castingstainless steel casting
Posted by df on 2009.10.17 at 10:25 a.m.
Stop lying about preterism being true you ignorant moron, stop treating God's word casually you ignorant moron, stop treating history casually you ignorant moron, stop parroting lies carelessly you ignorant moron, stop perpetuating the 70 AD myth you idiot. Read carefully for once you stupid idiot instead of casually farting your opinions all over the net and spreading error concerning God:
http://jesus-messiah.com/html/preterism-preachers.html http://www.bethelministries.com/preterism.htm http://www.therefinersfire.org/preterism.htm
Posted by Daniel Knight on 2009.10.27 at 12:52 a.m.
Post a Comment