Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44661 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67650 invoked from network); 2 Jul 2009 14:59:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jul 2009 14:59:57 -0000 Authentication-Results: pb1.pair.com header.from=ezyang@MIT.EDU; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ezyang@MIT.EDU; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain MIT.EDU designates 18.7.7.80 as permitted sender) X-PHP-List-Original-Sender: ezyang@MIT.EDU X-Host-Fingerprint: 18.7.7.80 BISCAYNE-ONE-STATION.MIT.EDU Solaris 9 Received: from [18.7.7.80] ([18.7.7.80:47872] helo=biscayne-one-station.mit.edu) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 34/5B-16153-C6BCC4A4 for ; Thu, 02 Jul 2009 10:59:57 -0400 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by biscayne-one-station.mit.edu (8.13.6/8.9.2) with ESMTP id n62EwiAX017438 for ; Thu, 2 Jul 2009 10:58:45 -0400 (EDT) Received: from localhost (ita4fw1.itasoftware.com [63.107.91.99]) (authenticated bits=0) (User authenticated as ezyang@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id n62Ewixr023658 for ; Thu, 2 Jul 2009 10:58:44 -0400 (EDT) Content-Type: text/plain; charset=UTF-8 To: internals In-reply-to: <98b8086f0907020755k1c29930n8a4cef38dbb61291@mail.gmail.com> References: <98b8086f0907020714m6c67fce3jab4d13429b3cd2a4@mail.gmail.com> <1246545959-sup-2910@javelin> <98b8086f0907020755k1c29930n8a4cef38dbb61291@mail.gmail.com> Date: Thu, 02 Jul 2009 10:58:44 -0400 Message-ID: <1246546647-sup-7740@javelin> User-Agent: Sup/git Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.42 X-Spam-Flag: NO X-Spam-Score: 0.00 Subject: Re: [PHP-DEV] constructors are callable as regular functions. From: ezyang@MIT.EDU ("Edward Z. Yang") Excerpts from troels knak-nielsen's message of Thu Jul 02 10:55:48 -0400 2009: > I understand that. It's not a technical issue - It's more a matter of > language semantics. Constructors are used for initializing state on an > object. Basically, this behaviour makes it impossible to implement > immutable objects in php. It's not a huge deal - I don't remember ever > seen __construct() called directly. Au contraire, you can employ this little trick: class A { private $a; private function __construct($a) { $this->a = a; } public function make($a) { return new A($a); } } But I agree; stab anyone who is doing $foo->__construct(). Except for testing. Testing is ok. Cheers, Edward