6 ms·
I'm glad you can now write: public static function new(): static { return new static(); } It really brings the point across it's static.
by stabbles 6y ago
I'm glad you can now write:
public static function new(): static
{
return new static();
}
It really brings the point across it's static.
- brendt_gd 6y agoI know you're trolling, but FYI the `static` before function has nothing to do with the `static` return type. Like other programming languages the term `static` is used to denote two things.
- stabbles 6y agoThe term is overloaded, which is a bit unfortunate.
- hashtagmarkup 6y agoHowever, the unfortunateness is static.
- ThePadawan 6y agoAnd other programming languages get away wihout overloading the term. It's not an excuse for slacking on language design.
- int_19h 6y ago"static" itself is originally an overloaded term, and still remains such to this day in C++.
- joseluisq 6y ago> It really brings the point across it's static. A bit better, due from 7.x backward it really doesn't transmit any sense to me. Just confusion. And I'm not alone. See https://www.reddit.com/r/PHP/comments/elrnp4/rfc_for_static_return_type/ https://www.reddit.com/r/PHP/comments/elrnp4/rfc_for_static_...
- diamondo25 6y agoWhy didnt they use the term singleton or object?
- jorams 6y agoWhat would they use it for? The first 'static' means the method is a part of the class rather than the instances of that class. The second and third 'static' indicate late static binding, meaning they refer to the class being called, rather than the class defining this method.
- quietbritishjim 6y ago(Disclaimer: I know absolutely no PHP whatsoever.) > The second and third 'static' indicate late static binding, meaning they refer to the class being called, rather than the class defining this method. Wait, so they're using "static" to mean the binding is happening later? Isn't that essentially less static than binding against the class being defined?
- spdionis 6y agoIt's still static in the sense that the method is tied to a class, not to an object instance. Does that mean it's "less" static? I wouldn't say so.
- quietbritishjim 6y agoWell then I guess we'll have to agree to disagree :-) It's less static than a method dependent on the object instance, but more static than a method that doesn't even depend on the class. If I've understood correctly (which I quite possibly haven't, in fairness), these are analogous to Python's static methods, class methods and regular methods, and its static methods really are the "most" static.
- pornel 6y agoC did it first: static a(int a[static 1]);
- codeulike 6y agoand new