Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86988 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32276 invoked from network); 1 Jul 2015 19:00:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jul 2015 19:00:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=aaron@icicle.io; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=aaron@icicle.io; sender-id=pass Received-SPF: pass (pb1.pair.com: domain icicle.io designates 199.38.81.6 as permitted sender) X-PHP-List-Original-Sender: aaron@icicle.io X-Host-Fingerprint: 199.38.81.6 mercury.negativeion.net Received: from [199.38.81.6] ([199.38.81.6:63301] helo=mercury.negativeion.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 99/60-20693-3D834955 for ; Wed, 01 Jul 2015 15:00:35 -0400 Received: from localhost (localhost [127.0.0.1]) by mercury.negativeion.net (Postfix) with ESMTP id 523F9275955D; Wed, 1 Jul 2015 15:00:31 -0400 (EDT) X-Virus-Scanned: amavisd-new at negativeion.net Received: from mercury.negativeion.net ([127.0.0.1]) by localhost (mercury.negativeion.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xGepvso_4jNN; Wed, 1 Jul 2015 15:00:30 -0400 (EDT) Received: from macpro.local (unknown [173.225.158.77]) by mercury.negativeion.net (Postfix) with ESMTPSA id 82166275954E; Wed, 1 Jul 2015 15:00:30 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) In-Reply-To: Date: Wed, 1 Jul 2015 14:00:29 -0500 Cc: pthreads@pthreads.org, internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <5873FC04-0579-41A6-86BD-9755A57CFED5@icicle.io> References: <1413875212.2624.3.camel@localhost.localdomain> To: Sara Golemon X-Mailer: Apple Mail (2.2098) Subject: Re: [PHP-DEV] [RFC] UString From: aaron@icicle.io (Aaron Piotrowski) > On Jul 1, 2015, at 1:06 PM, Sara Golemon wrote: >=20 > On Tue, Jun 30, 2015 at 10:36 PM, Joe Watkins = wrote: >> Another possible issue is engine integration: >>=20 >> $string =3D (UString) $someString; >> $string =3D (UString) "someString"; >>=20 > That sounds as a cool idea to discuss as a completely separate, > unrelated RFC, and not specific to UString. >=20 > e.g. $obj =3D (ClassName)$arg; /* turns into */ $obj =3D new = ClassName($arg); >=20 > So you could use casting with any class which supports single-argument > constructors. >=20 > But again, orthogonal to this RFC. >=20 > -Sara >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20 Expanding on this idea, a separate RFC could propose a magic = __cast($value) static method that would be called for code like below: $obj =3D (ClassName) $scalarOrObject; // Invokes = ClassName::__cast($scalarOrObject); This would allow UString to implement casting a string to a UString and = allow users to implement such behavior with their own classes. However, I would not implement such casting syntax for UString only. = Being able to write $ustring =3D (UString) $string; without the ability = to do so for other classes would be unusual and confusing in my opinion. = If an RFC adding such behavior was implemented, UString could be updated = to support casting. Obviously a UString should be able to be cast to a scalar string using = (string) $ustring. If performance is a concern, UString::__toString() = should cache the result so multiple casts to the same object are quick. Aaron Piotrowski=