Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95153 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73340 invoked from network); 14 Aug 2016 22:35:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2016 22:35:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.169 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.192.169 mail-pf0-f169.google.com Received: from [209.85.192.169] ([209.85.192.169:34746] helo=mail-pf0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/74-36656-E22F0B75 for ; Sun, 14 Aug 2016 18:35:27 -0400 Received: by mail-pf0-f169.google.com with SMTP id p64so11801086pfb.1 for ; Sun, 14 Aug 2016 15:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=ehw/qqIq2+3F7VwvKq8kGKnjc1gXqThLMeNJ5RFHh+w=; b=x+Et7JoXxd5dUcQQ+v22Z2OYrsZgn/HFJSDGRcgSZH0jfXe5ShdkqBuaKKlem5uU29 K6B+EoMRgI6STLWMv6QgAAn1weQtaxRNdh6iDMQCTgikU0fxKXiTokZ6ClwAuOSmurcK q3L4j8OAZoPFNPu40b9CREYdtIZZz45z1g8DqJrlKHnyMKOaC0JVSErz/p+gY4BwHRKK AOhpNKUMsmQnPpRppF1ZNFHON3DXs6uHrCqfuFQ0mDfRWxXUKvNm+MkcsRbjkY0X3chc H8dr5sN7i9R9YIun5du6WC0oSuNZg6pVzYSFiGF+Y2TUXqirYbhK205z4l15Nj8Lu4EN Fsmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=ehw/qqIq2+3F7VwvKq8kGKnjc1gXqThLMeNJ5RFHh+w=; b=ZkIj3nNql+BTaam2facYzDltpqP7MWjFaqJrpJFXiW3yekVkGOBaO8nVlxqdJ3k9I4 l7M6+bRfGW/fwYOvGd0cYjgYfLTScp1WxKkK6J/BFJ36QNtl2Uhomle0pjmtPulE8MkG p67XvVctGAm9k9OmUZerLCQ9cuRB1nZGLd2PXVlQuAcQeqmszT6u62t2QdF0JWD3f4bm ASOSReUZt+KWtAn//r0mDBe0sg7E6oz7QnumVOYwlN9vk+3QvfLP2lsKe2Ot9uw1/dzR un5kXdVyLhsJRG84U4T/KMOrfCcl+51L3dYSkvYWNd5v6OOZlSq3BIieGOBhk6/r+yG9 UbYw== X-Gm-Message-State: AEkoousRf8KSSPZJGMxToLpFl8OLaSY/xSgMOMLyj5gw1Lk4TIQAHnHg3r2BIh4249z5jg== X-Received: by 10.98.61.24 with SMTP id k24mr48729107pfa.100.1471214122997; Sun, 14 Aug 2016 15:35:22 -0700 (PDT) Received: from Stas-Air.local (108-233-206-104.lightspeed.sntcca.sbcglobal.net. [108.233.206.104]) by smtp.gmail.com with ESMTPSA id u1sm27996132pfu.12.2016.08.14.15.35.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Aug 2016 15:35:22 -0700 (PDT) To: "guilhermeblanco@gmail.com" References: <11f9c899-77b4-da50-f0f7-dc2d16b1829c@gmail.com> <431d5b9c-15ef-9af8-7a55-b776b2dd22ad@gmail.com> Cc: PHP internals Message-ID: <5d38c41d-f189-56d2-be58-d60be3fd1bd9@gmail.com> Date: Sun, 14 Aug 2016 15:35:20 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Namespaces internal refactoring From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > A realization that needs to be made is that beginners would be using > libraries that requires to make valid restrictions, preventing those > beginners to mess up with code they shouldn't. So even if the use case > is only valid for 0.01% of code producers, it might be valid for 20%+ of > consumers. I don't think PHP needs more bondage-and-discipline. If beginners "mess up with code they shouldn't" that is usually, in my experience, a sign of library authors not serving their use case well, and not implementing functionality that they need. Either because they didn't know, or because their opinion about user's needs differs from user's opinion about their needs. In this case, I'm on the user's side. Hacker's ethos is doing things other people think can't be done. > It's about defensive programming. > I never knew TopologicalSorter was used by several users until I > actually broke its API. Imagine the frustration of all those developers > with tight deadlines having to deal with a sudden breakage, because the > language it too open to notify them about something shouldn't be used. I'd rather say "imagine the frustration of all those developers that rely on the library authors who are oblivious to their true needs and still the developers at the mercy of them every day". I agree that can be frustrating. The solution is not more detachment from the needs of the users and more fencing out so these pesky users would have absolutely no way to use my code in ways that I didn't foresee, because I'm capable of foreseeing 100% of user's needs and if I'm not, it's their fault. At least, I don't think it is. > Every time someone questions me about the validity of private classes, I > like to exercise replacing the term "private" with "final". Final is > part of PHP language and it also there's non application that is > prevented without it. I think most of the usages of final are wrong too, and for the same reasons. It's a claim you have foreseen all user's needs and they'd never need anything else. It's usually wrong. > modifier, https://mwop.net/blog/2012-06-28-oop-visibility.html history > would be completely different. There Matthew says pretty much what I say, so I agree: I feel that frameworks and libraries should use private and final sparingly. > That's not about preventing for no reason and it should be bypassed. > It's about somehow telling users that something shouldn't be used at all. > The amount of people that takes the wrong approach is insane, and any > kind of prevention to do it is beneficial. If the amount of people using your library in a wrong way is insane, maybe something needs to be changed in the library? ;) If you build a nice slick walkway and people keep walking over the grass 100 meters aside, it may just be you've built the walkway in a wrong place. > I managed big teams of development where I work, and controlling code > produced by 40+ developers is not easy. > Countless classes are marked as final and I bet hundreds would be final > if I could. > Handling a company source code is easy through code reviews, and also > walk a few steps to ask why a certain class is final or (hypothetically, > private). Maybe it makes sense to a company which works on its own product, never to be used by others, and has every use of the code tightly controlled, foreseen and signed in triplicate with TPS reports on top. My opinion though it is more of a burden than a benefit to an open-source environment built on extending and modifying existing code. > I've walked through several scenarios of peers coming to my desk asking > to remove final because reasons and going out with a much simpler > solution without the need to remove it. That implies you are always smarter than any user of your classes and have foreseen their need in advance before they even were aware of them. It is nice to be a genius, unfortunately, there's only one of you, and maybe another dozen of similar geniuses in existence (I'm certainly not one of them, not even close). Others need to deal with situations where their code is used in situations where they did not foresee 100% of users' needs and some modification/extension should be made. Betting on being a prophetical genius is usually a losing bet. Unless, of course, you are. But I would rather prefer the flexibility of being able to correct my mistakes and shortsightedness than betting on that. Which means flexibility beats bondage-and-discipline. > Problem of lack of Annotations support... I've tried several times, and > made sure I was accessible enough to answer every situation or scenario > Doctrine faced and reasons for every decision taken on the library. > Still, people seem to ignore expertise and decide to take their own > methods which only solves (I'll use your numbers now) 0.01% of use cases. Unfortunately I am of opposite opinion - that the Doctrine needs - important as they are - are 0.01% of all PHP user's needs. And the fact that we don't have solution we could build on (again, you see the leitmotif I'm harping on - being flexible instead of trying to be ideal at the start and freezing there) because that solution won't serve *all* the needs appears very unfortunate to me. > When I mentioned allowing to assess imported classes, I mean this: > > namespace Foo; > > use Bar\Woo; > > /** > * @Woo\Fuzz() > */ > class Lala {} > > Annotation parser needs to understand what was "use"d, so it can > properly refer to FQCN. That way, we need to somehow discover something I see what you mean. This seems to be a problem because you are trying to do compiler things without the support of the compiler. I'd say the right solution is to let the compiler do these things... -- Stas Malyshev smalyshev@gmail.com