Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68677 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98267 invoked from network); 29 Aug 2013 11:00:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Aug 2013 11:00:34 -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 209.85.219.47 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.219.47 mail-oa0-f47.google.com Received: from [209.85.219.47] ([209.85.219.47:56339] helo=mail-oa0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 56/91-23883-1D92F125 for ; Thu, 29 Aug 2013 07:00:34 -0400 Received: by mail-oa0-f47.google.com with SMTP id g12so317381oah.20 for ; Thu, 29 Aug 2013 04:00:31 -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; bh=EfxIKfNhIyBrKiwleOgmhxisAzR7B+IJINoSkG/Q8sA=; b=JIhNfjFR7I92B1xfyS3Sr6RxARdVQ6wA2RMGF1YQ7cQiRxGiX7i7fyJY7TzEoM+l71 49RqzyTWej/s2J3UTMg7PbdGPuUw2ERK9H662jWLClj8FjwhcN/wtpgLw6bg2yzdtjb3 Tqd/AJpFgKZsVPwNlfpcPrdbKFmSTpUWYFZBMqhnqMJp4afBXHgT8NlnNSjSXiwunHp6 EgWGh7MBu8izrjeb0HKaYhW8el5IO7NhdVJY0K7HOThhS7WuMzkrvMCKKnpGN3XD3FKJ gyE/2cgAiMV+xiuSNAz8EQCQzUvMT76AOybQz2uYq/L/1pTI/tFw6Sf1kqg59+pkxppC zBKw== MIME-Version: 1.0 X-Received: by 10.182.98.162 with SMTP id ej2mr1861745obb.61.1377774031181; Thu, 29 Aug 2013 04:00:31 -0700 (PDT) Received: by 10.182.98.8 with HTTP; Thu, 29 Aug 2013 04:00:31 -0700 (PDT) In-Reply-To: References: Date: Thu, 29 Aug 2013 13:00:31 +0200 Message-ID: To: Julien Pauli Cc: PHP Internals Content-Type: multipart/alternative; boundary=047d7b2e46f0b59cf404e514034b Subject: Re: [PHP-DEV] Refactored magic methods From: nikita.ppv@gmail.com (Nikita Popov) --047d7b2e46f0b59cf404e514034b Content-Type: text/plain; charset=ISO-8859-1 On Fri, Aug 2, 2013 at 6:47 PM, Julien Pauli wrote: > Hi internals. > > I started a work of refactoring magic methods from internals. > > The first goal was to never write ourselves things like "__get", but use > macros for those names. (get, set, invoke, etc...). > > A second goal was to rewrite some parts of the compiler which looked like > code duplication which could benefit from macro refactoring. > > I did that. > All tests pass. > > It may look uglier for people who dont like having more macros, but anyway, > we can cherry pick some commits, etc... > > If you have ideas or things to say, I'm listening. > https://github.com/jpauli/php-src/compare/macroing > I'm not really a fan of heavy macro usage, so here an alternative suggestion: https://github.com/nikic/php-src/commit/375bd7911fd117696b8b5d63c104fd588d69c409 Basically, instead of going through all the magic methods manually we define a structure holding information on magic methods and then loop through it doing generic checks. The above example only changes zend_check_magic_method_implementation, but the idea can be generalized to the other occurances of magic method checks (making the structure a global constant so they can all make use of the information in there.) Nikita --047d7b2e46f0b59cf404e514034b--