Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72981 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74705 invoked from network); 6 Mar 2014 17:29:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Mar 2014 17:29:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=chobieee@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=chobieee@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.45 as permitted sender) X-PHP-List-Original-Sender: chobieee@gmail.com X-Host-Fingerprint: 209.85.160.45 mail-pb0-f45.google.com Received: from [209.85.160.45] ([209.85.160.45:61716] helo=mail-pb0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/64-52599-090B8135 for ; Thu, 06 Mar 2014 12:29:53 -0500 Received: by mail-pb0-f45.google.com with SMTP id uo5so2909372pbc.4 for ; Thu, 06 Mar 2014 09:29:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=XhKAYBzCEcGFwLPjXHJuSM9QeF2anGCcw3bGy96vPdY=; b=ASbpafWJgcy3YtSzS1IdQngbndNhrhypZjXB+PvcCYzXUI+/oXkYHwVcDJod/I5oyR 9waCSqSUWJ0KekYSLMID8BnmlSmHtE9Q9fbybc6PYgthsmPR9m+tK2wvB/mlv1NTh6/8 0zCkeE0biLJBu9yLje1yVmnAg57DgZfuws5HVtH8JAu6ORtR00E7fFY+NEpf7ZTrHWrX EpIEfiFc4kTQsWLGmmA5P0U7LJZSgec4BFErKlFKdBPtLN2Esar3+quM972X0t3EXQNQ b+jOGat3X6MsdPh8jJ7NajQThEbjjbKbSMZsRlTzP6w+2WAKHb6mvcG8Dop24Tk4nFkB TWmg== MIME-Version: 1.0 X-Received: by 10.66.138.40 with SMTP id qn8mr16107757pab.154.1394126990033; Thu, 06 Mar 2014 09:29:50 -0800 (PST) Sender: chobieee@gmail.com Received: by 10.68.204.198 with HTTP; Thu, 6 Mar 2014 09:29:49 -0800 (PST) In-Reply-To: <531675D6.1030203@sugarcrm.com> References: <5307B1FE.1020604@marc-bennewitz.de> <531675D6.1030203@sugarcrm.com> Date: Fri, 7 Mar 2014 02:29:49 +0900 X-Google-Sender-Auth: lEc-vDUmLc9blkNp9Pt5FKk6Gbk Message-ID: To: Stas Malyshev Cc: Marc Bennewitz , PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [php6] OOP resources From: chobieeee@php.net ("Shuhei Tanuma (chobie)") Again, previous email completely broken my English and thoughts. so please don't reference it ;'-( 2014-03-05 9:54 GMT+09:00 Stas Malyshev : > You don't have to do anything different there - you can still use the > same API. With minimal effort, you can also make the API dual-purpose, > i.e. foo_bar($foo, $bar) and $foo->bar($bar) would do the same. But it > doesn't have to be that, you can also stay with foo_bar($foo, $bar) and > have $foo as object. I've maintained extensions which uses several entrepreneurial libraries. like libgit2, libuv. Occasionally, those libraries brakes BC. then I have to get rid of some OOP interface when they broke it. Eventually, I prefer procedural interface to object oriented programming in that cases. (also, writing an extension generator for procedural interface is easy work. it's very handy) Well, regrading resource object. let assume try to implement `git_repository_index` function. (git_repository_index fetches index pointer from repository pointer.) int git_repository_index(git_index **out, git_repository *repo); PHP interface would be this: `GitIndex git_repository_index(GitRepository $repository);` GitIndex and Git repository are represents of resource objects. and I choose procedural interface for maintainability reason. But in this case. Most developer expects `$repository->getIndex()` API isn't it? even maintainability reason. So I think Resource object forces OOP paradigm. And I realized resource object has another effect. for example, libuv has several structures. I have to implement right resource inheritance for those structures, right? like UVTcp extends UVStream, UVStream extends UVHandle and UVHandle extends Resource... It would be better to implement OOP interface than choosing Resource object I think. > What would be the difference? It's pretty much the same API and macros > can be added to eliminate any boilerplate code. See how it's done in > intl, for example. yea, I've checked it. and this is trivial thing for PHP6. please never mind.