Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74773 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73061 invoked from network); 6 Jun 2014 07:10:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2014 07:10:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=nicolai.scheer@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nicolai.scheer@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.43 as permitted sender) X-PHP-List-Original-Sender: nicolai.scheer@gmail.com X-Host-Fingerprint: 209.85.216.43 mail-qa0-f43.google.com Received: from [209.85.216.43] ([209.85.216.43:56515] helo=mail-qa0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 56/81-63196-25961935 for ; Fri, 06 Jun 2014 03:10:12 -0400 Received: by mail-qa0-f43.google.com with SMTP id m5so3067120qaj.16 for ; Fri, 06 Jun 2014 00:10:08 -0700 (PDT) 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:content-transfer-encoding; bh=uxUv3FiG8CuduNE5Gkcfc+JLlw7lgIAK9QCDGwTKDWE=; b=qSf4W5Kd0OolHwoxyUbj8iusyVTTROoMXYWZjD4rdja5cpvv3PJw0iBTGel6YtDnTx PRpKpV1bXdnEonhGMuX1ZYH5W25ew1GauI6MJxfMRvhR2sYG+XOgU0qnK77tY62q+CIx Y+39A4pTHuWnUi+DUPw8ykm1hF1fJzvJ2P3Jn88XxiUtuQ4s+wpPWBaMHlKey2kGuo9P gMTXs0+aHhq27QT2E2RTHUItZDEzwtbgxXCOOz7btT5+jS9rxzFvJjdmIe4DiiM+NcQK 3Y6Mf0u2wptgsl6QdsHU8AdWBmRKE6DIQKEcT9OWO8nC2Xadw/xcNUNr/QNn7WGJ1uoc IMKg== MIME-Version: 1.0 X-Received: by 10.140.95.80 with SMTP id h74mr5098171qge.2.1402038608452; Fri, 06 Jun 2014 00:10:08 -0700 (PDT) Received: by 10.170.88.215 with HTTP; Fri, 6 Jun 2014 00:10:08 -0700 (PDT) In-Reply-To: <1402007179.2282.209.camel@guybrush> References: <1401917648.2282.175.camel@guybrush> <1402007179.2282.209.camel@guybrush> Date: Fri, 6 Jun 2014 09:10:08 +0200 Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] zend_API.c - missing zend_update_property_resource From: nicolai.scheer@gmail.com (Nicolai Scheer) Hi! On 6 June 2014 00:26, Johannes Schl=C3=BCter wrote= : > On Thu, 2014-06-05 at 21:21 +0200, Nicolai Scheer wrote: [...] > >> > * Usage of resources is discouraged, instead of a resource use a= n >> > object (extend zend_object to store pointers etc.) >> Didn't know that usage of resources was discouraged... Nearly all my >> knowledge comes from Sara's great book (btw. if you read this Sara, I'd >> love to see and buy a refreshed version!) and my own field tests. >> When you say "use an object", do you refer to the way described in [1]? >> From what I've read so far, this way sounds more complex than just >> registering a resource. >> Could you elaborate a bit on the rationale behind this recommendation? > > They are (incomplete list) > > * slower than objects for many operations > * have an api with some weird behavior (some operations give > errors which are hard to catch as extension author) > * any people consider OO APIs nicer > * resources can't be introspected by PHP level debuggers, var_dump > etc. whereas objects can provide required hooks I see. In fact I use an OO API, ist's just that the object internally stores a connection resource (i.e. a struct containing stuff I need) in a private property. The first version of the extension was not OO, so it seemed straight forward just to wrap the connection resource within a class, so that you don't need to pass it around in userspace all the time. Extending zend_object to store my data structures sounds as the next I should take to further "objectify" my extension. Thanks for the pointers! Greetings Nico