Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61373 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85835 invoked from network); 17 Jul 2012 18:47:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jul 2012 18:47:23 -0000 Authentication-Results: pb1.pair.com header.from=indeyets@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=indeyets@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: indeyets@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bk0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:33912] helo=mail-bk0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 81/16-54353-A33B5005 for ; Tue, 17 Jul 2012 14:47:23 -0400 Received: by bkcjm19 with SMTP id jm19so696183bkc.29 for ; Tue, 17 Jul 2012 11:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :message-id:references:to:x-mailer; bh=GsFRsDX6fGHDKYeQF073/vIZ0IY9ToQQVINh+QwB/9U=; b=Hf7WCT0hnuCiMT7SGwTsJ72fDx0kQM92gqnhqiIQjkM2TARZ4cTJy8nnfYarC4tmah IYG6QzU30KakCNBeo7lkOhWynV97oMPu7w+CoG9Xulm0oLP8+DEM7dgVU0AXfaPCoToD EvOIGT3XDXb9rWcxPuca6aMfL9w2ffArPbslgpcoWco+RJKVy2QPUkimD7cuxn7+EXvn ZsjfKvAclzFOzfJCIfJNqrxf9EfrwN2TbG+EW5yRt55EyNsBgAnB1anh8dPIiT6p+OfK JXNcikfTs543/8Z+4BTt9l8X63Gf03nXzcIMSYtSqrWwLyNOKo3n4G9cqbG3m7ERCyM0 1FOQ== Received: by 10.152.104.44 with SMTP id gb12mr3832821lab.29.1342550839694; Tue, 17 Jul 2012 11:47:19 -0700 (PDT) Received: from [10.0.1.7] ([93.185.190.227]) by mx.google.com with ESMTPS id o5sm4284927lbg.5.2012.07.17.11.47.16 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Jul 2012 11:47:18 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: multipart/signed; boundary="Apple-Mail=_C37EE575-919E-4F83-B029-51B963F249CD"; protocol="application/pgp-signature"; micalg=pgp-sha1 In-Reply-To: <5005A5E4.2030004@sugarcrm.com> Date: Tue, 17 Jul 2012 22:47:13 +0400 Cc: Pierre Joye , Gustavo Lopes , internals , Andrew Faulds Message-ID: References: <50059AF8.5050805@sugarcrm.com> <9430CE0C-7DA4-4655-92D5-056E12A7BC74@gmail.com> <5005A5E4.2030004@sugarcrm.com> To: Stas Malyshev X-Mailer: Apple Mail (2.1278) Subject: Re: [PHP-DEV] Pseudo-objects (methods on arrays, strings, etc.) From: indeyets@gmail.com (Alexey Zakhlestin) --Apple-Mail=_C37EE575-919E-4F83-B029-51B963F249CD Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 On 17.07.2012, at 21:50, Stas Malyshev wrote: > Hi! >=20 >> I am for making array a proper class with methods. >>=20 >> "Legacy" functions can be implemented as wrappers around it: >>=20 >> function array_push(&$array, $value) >> { >> $array->push($value); >> } >=20 > The problem there is that array has different semantics than object. = Not > completely, but for example if you pass array to function, it is = passed > by value and is not modified, but objects are always mutable when = passed > to functions. Changing this semantics will break a lot of code. Having special handling of Array objects doesn't sound good too. And I = don't see any nice solution. Options are: * "5-to-6" tool, similar to python's "2-to-3" converter, which will fix = code. * introduce some kind of per-file declare() option, which would enable = pass-by-reference semantics of arrays/strings/etc. in 5.5 which would = let people write the same code for 5.5 and 6.x Well, actually, there's one more option: we can introduce "Autocloned" = interface (empty, without methods) and force "cloning" of objects, which = implement this interface, during parameter-fetching phase. This would allow us to have 2 sets of classes: One set which implements = this interface (slower, but backwards-compatible) and another set which = doesn't (faster, but not compatible).= --Apple-Mail=_C37EE575-919E-4F83-B029-51B963F249CD Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) iQEcBAEBAgAGBQJQBbMyAAoJEM8kLGy4PJ4JlAcIAJ/YYFYiLoYqlTLjR1+svvNS 4bk/VlsdcguCyPvvDddcfiyIdwrz9+G1YCgXBMjJVRZXsIM5yQgbsuncEwnj7x/h SuHfT9+9WNgseRAIfNz8iOFG9MrmI5SiSwEipus/Yg+VAbq4JyFYLElvJqPZomvs chonSfeb5PcuIBujjBT8vJvh8qJGuRoy896KsM+zn17yoqAocnIYjOrRPIH7sQ/6 wAn9M8IiuJeFrR+3ag/og8muAOdCIFMewErn2L+VESCSutza1FzNab9AdKyyJc6K LHe2JuJNl1q3dxXGlMyZ2nOJW3uSBGwcAcgoaDxocE1ECD2L4qRQP/dvKDx4TlA= =sj57 -----END PGP SIGNATURE----- --Apple-Mail=_C37EE575-919E-4F83-B029-51B963F249CD--