Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89173 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48559 invoked from network); 11 Nov 2015 10:28:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Nov 2015 10:28:42 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.53 mail-wm0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:35298] helo=mail-wm0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/00-48205-75813465 for ; Wed, 11 Nov 2015 05:28:41 -0500 Received: by wmdw130 with SMTP id w130so106989085wmd.0 for ; Wed, 11 Nov 2015 02:28:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=e04lQjrlLQPRMswEOoPWTIT1ZhiNLtGD4qDGwQDXL1A=; b=vzjJeiDXTyoAwSeo4WfSSu9c8Peh3SbLrjxTPV5Yqx0N6V1zP2DmeHTRsQaQgme9oe +UExo8jbjYmI1MACes2ZU3NOIrnHcYdLvGzZhAPTPYpUp71tlwqGPQ3GAmQRcvT60K4r HnGn7r7kYYa+GNAteQ2TJ/CejaiNr3FJWGiaH/mH/+jvMKW0XeHXblRTmhmzmG6jX+nZ nJRFp03kqBfjbR76Zt+chyqmdaJVl3NqFEYZSP5PJ+oRL7tIjzpbOEnt2vxEVqeEFnNJ SbRQKIGFnONLHWjFzs0TlLSHC2pPyx/OCOdGZrdSkLvIr8ucqucnQeHSBG44K246olLO OvyA== MIME-Version: 1.0 X-Received: by 10.28.35.203 with SMTP id j194mr5758955wmj.13.1447237716971; Wed, 11 Nov 2015 02:28:36 -0800 (PST) Received: by 10.27.84.70 with HTTP; Wed, 11 Nov 2015 02:28:36 -0800 (PST) In-Reply-To: <5642A801.3050909@dasprids.de> References: <56429DAB.6010005@dasprids.de> <5642A801.3050909@dasprids.de> Date: Wed, 11 Nov 2015 11:28:36 +0100 Message-ID: To: "Ben Scholzen 'DASPRiD'" Cc: PHP internals Content-Type: multipart/alternative; boundary=001a113eb39606961a0524414aa7 Subject: Re: [PHP-DEV] Re: Resource typehint and return type From: nikita.ppv@gmail.com (Nikita Popov) --001a113eb39606961a0524414aa7 Content-Type: text/plain; charset=UTF-8 On Wed, Nov 11, 2015 at 3:29 AM, Ben Scholzen 'DASPRiD' wrote: > On 11.11.2015 03:21, Andrea Faulds wrote: > >> The reason for this is that the resource type is an anachronism from an >> age in which PHP did not have objects, yet still needed to make certain >> types of data opaque. The resource type is a type that exists only to >> shuffle around C pointers between internal functions. It has no semantic >> value. Because resources are now redundant, given the existence of >> objects, their time is running out, and they will be replaced at some >> point. Adding a type declaration for resource would mean that code using >> it would break if we replace any existing usage of resources with >> objects, preventing migration away from resource. >> > > I see, I didn't really know about this. Although right now, we still use > resources to pass around the fopen() pointers. Do you mean that it is > planned to have a read/write object like we have in e.g. Python (supplied > by the open() function)? > The long term plan is to do transitions similar to the one which GMP underwent: It uses GMP objects since PHP 5.6 and was using resources previously. The API is still the same (procedural), but we could now add an additional object-oriented one as well. Before this transition can happen comprehensively, we will have to add support for persistent objects. In addition to what Andrea said (resource type hint causing issues should we choose to migrate to objects), I also think that the resource type hint provides relatively little value in itself. It only says that you are accepting *some* resource. However, resources are many. Is this a file handle? Is it a database connection? Is it a streaming hash context? It doesn't tell. "resource" would be the analogue of an abstract "object" typehint (rather than a specific class/interface hint), which notably we do not have either -- the cases where it would be useful, i.e. the cases where you are working on *arbitrary* objects (or resources) are relatively few. Nikita --001a113eb39606961a0524414aa7--