Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69481 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 745 invoked from network); 4 Oct 2013 12:50:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2013 12:50:46 -0000 Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 74.125.82.50 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 74.125.82.50 mail-wg0-f50.google.com Received: from [74.125.82.50] ([74.125.82.50:59890] helo=mail-wg0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/71-24156-4A9BE425 for ; Fri, 04 Oct 2013 08:50:45 -0400 Received: by mail-wg0-f50.google.com with SMTP id f12so4092012wgh.5 for ; Fri, 04 Oct 2013 05:50:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=2nD00ZA2lOCtNOQEw07OgjjgWqHynNQsXyMlv3GfxPI=; b=Tm8EiRGjyT1FAh51UUIBF+I5QiLv5vGacUj+nsI+Or6nrAvNPrCHIkBm4irLkvFoUV PTD/JJ0316t/CdApmJdF7EdkWSRqzNGEQnKV2wGc5TkwFBvjbmCF8mbDJA7WFUuw+4E0 UflnaCw5GtVjxFQnzlhJWFElYtSy2nH511APaL+xNJkNSUZicusXojMpmZMX/l7qvf2E YYDBUzrtSLKV5Mcn5SM6/Z6DKqDszblubMIWkX7/BCPMzTzWOTiuVwbCdXcHwsPSMIwL ZaiLt7zaHb0EZuKAdZDWcxyWnGsfcKQMYYC/T5/RKdaKXZ8eIe0ca8mJYb/fE1UuSUrN D+7Q== X-Gm-Message-State: ALoCoQngsFUgRH5bKXdOjfSPzbPbSpGSEVFxIl0sg+9cxKOTSHKf8MwsZd2apTfjIFLNPGIix4Vd X-Received: by 10.180.219.8 with SMTP id pk8mr7108464wic.58.1380891041248; Fri, 04 Oct 2013 05:50:41 -0700 (PDT) Received: from [192.168.0.3] (cpc22-asfd3-2-0-cust209.1-2.cable.virginmedia.com. [80.4.21.210]) by mx.google.com with ESMTPSA id ey4sm9760934wic.11.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 04 Oct 2013 05:50:40 -0700 (PDT) Message-ID: <524EB99E.4040307@pthreads.org> Date: Fri, 04 Oct 2013 13:50:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Clint Priest CC: internals@lists.php.net References: <5D.40.07863.EB798425@pb1.pair.com> <524EA254.1000109@php.net> In-Reply-To: <524EA254.1000109@php.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: Draft: Nested Classes From: pthreads@pthreads.org (Joe Watkins) On 10/04/2013 12:11 PM, Clint Priest wrote: > On 9/29/2013 4:12 PM, Joe Watkins wrote: >> https://wiki.php.net/rfc/nested_classes > One issue I see from a maintenance perspective (of the user of this > feature) is that you could end up having files with dozens of classes, > it would be nice if it dot have to be embedded within the class but > rather kept in a separate file. > > Alternatives: > > foo.php > -------- > namespace s; > > class foo { > } > > bar.php > -------- > namespace s; > > private class bar { > public for s\foo; > } > > /* This has the advantage of access control being kept in the > declaring class (bar) */ > > ---------------------------- > > foo.php > -------- > namespace s; > > class foo { > use s\foo as private; > } > > bar.php > -------- > namespace s; > > private class bar { > } > > /* This has no real advantage over the prior alternative but just > another possibility */ > > ---------------------------- > > Ultimately I like the feature, even if it could only be done in a > nested fashion. Given the original proposal, could something like > this work? > > bar.php: > -------- > abstract class abs_bar { > } > > foo.php: > -------- > class foo { > private bar extends abs_bar { > } > } > > -Clint > Morning, I've heard the multiple files thing several times now ... while I like the idea, I think it might just confuse users, what would a namespace be if classes supported this .... I think let's not stand on the toes of namespaces, it also goes contrary to the best use case of the feature, if we leave it out then it cannot be abused or cause confusion ... This simplifies the use of classes with a modified visibility I think, because we can define rules that are class-centric: private class: available to any class in the same virtual namespace protected class: available to any class in the same global class public class: available to any class Note: ("class" includes interfaces, traits, and abstracts, they can all be nested and declared with modified visibility too) private static method: available to any class is the same virtual namespace protected static method: available to any class in the same global class public static method: available to any class I don't think we should touch the functionality of normal method calls or member access, though static member access may need adjustment ... I've had a degree of success getting access to everything from anywhere, so I'm open to well thought out ideas there ... This is the clearest definition that I can think up and make work right now, it means that from the level of the global class outward to the namespace, all the way to the global scope, nothing is touched, everything is still the same. The only changes, and the only place those changes have any impact are at the level of the class, outside of a global class it's operation and inheritance as usual. From the global or namespace perspective a public nested class is just a namespaced class, the rest, it is not even aware of. Ultimately, I think your last example will be the solution to large projects utilizing nested classes, where they feel they must cross the file boundary: normal inheritance where the final/concrete classes are nested, sharing among them common public abstracts/interfaces from some other scope/namespace. This more or less keeps intact the black box, since access to abstracts/interfaces directly is not useful, and the final implementations are kept private by nesting. There appears to be a feeling that things are moving a bit too fast for 5.6, I feel obliged to delay this and anonymous classes until 5.7, if anyone has any input, I'll be opening the vote on monday or tuesday next week for anonymous classes, I'm considering delaying both until 5.7 ... Cheers Joe