Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121786 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 84362 invoked from network); 23 Nov 2023 18:10:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Nov 2023 18:10:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8C764180031 for ; Thu, 23 Nov 2023 10:11:02 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail.online-presence.ca (online-presence.ca [216.128.176.244]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 23 Nov 2023 10:11:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=online-presence.ca; s=default; t=1700763057; bh=D6N+EIpet6pfFUm/EqU//n8peymmoph55GiLeV6Jhmg=; h=Date:Subject:To:References:From:In-Reply-To:From; b=baPdUusEh4dVLwnosbkrR87624hca4lr8T1S2VNRcYsrYR9ekCnteI/JWsqlHJpK4 Wy08jJQT+uWB+1U86iznxuUifTasxVEMtLRa801csdpTED5sIf0mi173XgnQzneDMw czUoab5bxDIlCXo72uoihaTmzlBUiNfFdjt1wbqhqKsBQ+4WhIqVBKZ0w6Ot1vnyV9 yG/YbNx/bIkszuojuiiGOWl7qzH5K2JASuxmKQAwo2V8pcZ6RcWs2dkp8FlFC9E66i 6zmEUg2yhdXdoVuX8Z2r/2s+YMnnRDb8gycpVQRUNT4UegdxHHUlNMYGrv6vJlIY9v R3Z99C9HO8MMQ== Received: from [10.0.0.211] (S01064075c3d865eb.ed.shawcable.net [70.74.109.64]) (Authenticated sender: lanre@online-presence.ca) by mail.online-presence.ca (Postfix) with ESMTPSA id 801C2105CB7 for ; Thu, 23 Nov 2023 18:10:57 +0000 (UTC) Message-ID: <20e2eaf4-d6ae-454c-9727-76941df0a48c@online-presence.ca> Date: Thu, 23 Nov 2023 11:10:55 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: internals@lists.php.net References: <79d675e3-95b4-40bb-baf4-3e1c998f5390@online-presence.ca> <34979AED-893F-45DD-B641-A9F4F39B2928@newclarity.net> <2D505086-6AD9-4596-A515-85B50F5D12C5@koalephant.com> <44083842-40a7-43a0-b85b-b021356e7f70@app.fastmail.com> Organization: Online Presence In-Reply-To: <44083842-40a7-43a0-b85b-b021356e7f70@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC Proposal - static modifier for classes From: lanre@online-presence.ca (Lanre Waju) Seriously? Are you really this stupid or just feigning ignorance? How is this a global: class X { private static $count = 0; } I am no longer pushing this RFC because idiots like you are in charge of the votes but seriously your argument is dumb as fuck. If you aren't sure then why say anything before looking more into it? A class level static is not equivalent to a global in any sense and if I have to explain the differences to you, you are not in a position to be speaking this confidently. This isn't me taking anything personally, i have just come to the realization that this community is not for me, so you guys can have fun jerking each other off, and I will keep my ideas to myself. Cheers, Lanre On 2023-11-23 10:55 a.m., Larry Garfield wrote: > On Thu, Nov 23, 2023, at 1:43 AM, Robert Landers wrote: > >> I'd venture to say that static classes have some unique benefits over >> plain functions. One, you can encapsulate state using private static >> variables. That simply isn't possible with regular functions (unless >> you use static variables in the functions themselves, which isn't >> quite the same thing). > It's close enough to the same thing that it has the same problems. > > As far as I am aware, a static variable in a function is stored in global memory as a singleton. It's logically the same as a global variable, but with access restricted to one function. > > A static property of a class is also stored in global memory. It's logically the same as a global variable, but with a funny name that has colons in it. It may be access restricted depending on the code. > > (Engine experts, if I am subtly wrong there please do correct me.) > > So static variables and static properties are both simply "globals with funny extras." And global-maintained state is well known and understood as a bad idea that hinders testing, refactoring, tractability, maintenance, and everything else developers care about. > > Using global state, with or without funny syntax around it, is the anti-pattern we should not be encouraging. > > Generally speaking, even my prototypes eschew globals and statics in 95% of cases. > > --Larry Garfield >