Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97752 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49705 invoked from network); 14 Jan 2017 14:58:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2017 14:58:22 -0000 Authentication-Results: pb1.pair.com header.from=giovanni.g@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=giovanni.g@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.66 as permitted sender) X-PHP-List-Original-Sender: giovanni.g@gmail.com X-Host-Fingerprint: 209.85.213.66 mail-vk0-f66.google.com Received: from [209.85.213.66] ([209.85.213.66:35780] helo=mail-vk0-f66.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/97-00729-D8C3A785 for ; Sat, 14 Jan 2017 09:58:22 -0500 Received: by mail-vk0-f66.google.com with SMTP id 23so5727272vkc.2 for ; Sat, 14 Jan 2017 06:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Zp1Vl+nDhDGPM4068nIA7Qd3IbMexubzSXqlk2WH/f8=; b=J7Bdz4NMC8bIOhj4ny+L1Cl4ulNWDlbwZ3izJKXF9IPSrq9kzlfKBrJng6X2xawimT qMB6KfgaU3riF94D1LZPGAmVjXJ3jbvW+KLJyaS9xMgaNcwE9NLZTJKjiRydHxwlGpC5 Zetvxir8WFsqUyOBS0naxpI16+QES6J+6VUfb7gvAI51B/XCzZdPtyLScYchdnu8okmv G+EvvpO+cl5q5eVskmNaNWFhC/5ZbupC18o+XnVwQikkWqHqdQ5COaxBvSvo7lyRiSK1 FMsPZqOR5CDF5x/WlvnSFkvkUD8Pn0uItFN6EQSvYjrBpV+etdECUqYg9aqqm+HX5Ywn X5SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Zp1Vl+nDhDGPM4068nIA7Qd3IbMexubzSXqlk2WH/f8=; b=V6CjmOuwgZhUG/yLml7ij0bUUgwa7OJTHXlQm8F5ANcGyDUWFftndNKWwIBDiDfl7J TEomJrj+2NybFd1E1B1ZlFlpEPxOWdfqbvwZojZ4ohEeHXIQENtujgToSNlyi+8B3mjo V8PYGKCYRvXORkIS2Q8ZTIB1UJRg/znPwNSSYX2aSeyDIcpqRvAOz4GovhMvrhAc+pVJ KbaS0A89wkgPxYtU30GNgzKDHDOwWS1WIRXDlmFKcXoA9yq8EGWgL3oohq2hh9HlNtbQ TVlm0sVTqf1YsKNfENKJMHz1E6jvsvzOsqNpOQaI2mfHkK9gslhMbekrvA1/To6BpCiK 8pRw== X-Gm-Message-State: AIkVDXI5DHNyFrrS0E9+/L5OV+ihekvxuI0F/oSYTNMYl0EyH48SRLPpKN/xAAqOhlzAUlKORsABSCdDzien8Q== X-Received: by 10.31.107.74 with SMTP id g71mr18892vkc.116.1484405898745; Sat, 14 Jan 2017 06:58:18 -0800 (PST) MIME-Version: 1.0 Sender: giovanni.g@gmail.com Received: by 10.103.113.134 with HTTP; Sat, 14 Jan 2017 06:58:18 -0800 (PST) In-Reply-To: References: <0DE25BF8-D349-48EF-A83B-8837DD4AD1E0@gmail.com> <5efcc230-c67b-4439-cc82-b31eacbf36db@php.net> <7c8c8801-a849-6fd2-91e9-954030c55e83@fleshgrinder.com> <2051639b-1b63-2e44-51b0-381caa54dfd0@fleshgrinder.com> Date: Sat, 14 Jan 2017 15:58:18 +0100 X-Google-Sender-Auth: 50Op7SwbgwVrVWb9FlSYgmW5TCw Message-ID: To: Andreas Heigl Cc: internals@lists.php.net, Wes , sebastian@php.net Content-Type: multipart/alternative; boundary=001a114791004c1cb105460f2e4e Subject: Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch From: giovanni@giacobbi.net (Giovanni Giacobbi) --001a114791004c1cb105460f2e4e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I'm surprised no one is raising a strong argument about the "parent::__construct()" call, so I'll do it. I never liked typing "parent::__construct()" to call parent's class constructor, but now that this proposal is being discussed (and might even be accepted) I would like to throw some more meat to the fire: __construct(10, 20); s= o I don't see why I should type that method name inside my derived constructor. I just need a special syntax to do so. And while I'm at it (a bit offtopic but related to my previous argument) how about *not* requiring __construct() to be defined in the parent class? I.e. when you call parent::__construct() if there is NO constructor defined in the parent class just do nothing instead of going fatal error. I *always* wanted this feature, because when you do "new C;" it doesn't go fatal error if there is no __construct() defined. I don't think this is breaking covariance if you assume that every class defines an empty __construct() with no argument. I mean, if you later add an explicit constructor to the parent class it *must* be without arguments unless you accept you might break something. Thanks! On 14 January 2017 at 13:15, Andreas Heigl wrote: > > > > Am 14.01.2017 um 11:26 schrieb Fleshgrinder : > > > >> On 1/14/2017 11:20 AM, Andreas Heigl wrote: > >> Do we as "makers of PHP" want to dictate the user what the "intended" > >> behaviour of PHP is? Or are we treating the user as a responsible pers= on > >> that knows what to do and also not to do? > >> > >> Personally I'm in favour of the later. Let the user be able to call > >> __construct whenever they like. It's a special method which is clearly > >> visible by the two underscores at the start. So the users either know > >> exactly what they are doing or they need to learn it. > >> > >> Translated to a different example this discussion is like: "Let's remo= ve > >> the handle from the window because someone might be able to open the > >> window and jump out of it". The handle is there for a valid reason. An= d > >> as a window-maker I have no idea in what way it might be used. But I > >> have to accept that there are people missusing it. But should I limit > >> all those users with a valid use-case for it just to save some from > >> missusing it? And if we start with that, where should we stop? > >> > >> Just my 0.02=E2=82=AC > >> > >> Cheers > >> > >> Andreas > >> > > > > Yes, that is exactly the question. This needs to be voted on. Rust woul= d > > be an example that protects you and C/C++ would be examples that do not= . > > Both approaches are valid approaches. > > > > Note that the dictation will not always work, this is why e.g. Rust has > > unsafe blocks. The corresponding thing in PHP imho would be reflection. > > Hence, if someone has a special case: > > > > - Rust: use unsafe > > - PHP: use reflection > > > > -- > > Richard "Fleshgrinder" Fussenegger > > IMHO it already IS safe. > > In PHP 4 the "constructor" was a method thad had the same name as the > class. But now it is a class that has always the same name and is always > preceded with two underscores. There is no way to "accidentaly" call that > method. You have to explicitly call "__construct" to "break" things. > > If developers "want" to break something they will find a way. Protecting > "__construct" will not stop them from doing so. But it will stop the rest > of us do legitimate things. > > Cheers > > Andreas > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Giovanni Giacobbi --001a114791004c1cb105460f2e4e--