Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83109 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20147 invoked from network); 18 Feb 2015 19:30:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 19:30:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=lisachenko.it@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=lisachenko.it@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.175 as permitted sender) X-PHP-List-Original-Sender: lisachenko.it@gmail.com X-Host-Fingerprint: 209.85.212.175 mail-wi0-f175.google.com Received: from [209.85.212.175] ([209.85.212.175:46151] helo=mail-wi0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F4/A5-25021-358E4E45 for ; Wed, 18 Feb 2015 14:30:28 -0500 Received: by mail-wi0-f175.google.com with SMTP id r20so43439312wiv.2 for ; Wed, 18 Feb 2015 11:30:21 -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=FpHFN3XvblA/snAuFEFTCEBrcVD2ud2vRrM5M5j41lk=; b=tTo8CRfSB7N1IqyUK9k6BFH8FRBjBHRoziA9Xn4vZtUUex34xx0WcSOoztJN4e85d6 xUBl5bNWH5NcJd9r/Cb4dwkk8EUwGM56zsdGxO7Yrt7K5gY5sMd/feUEfXBHw+hUNcKG 1o3k6xN1ShcOl2PNqbpMiJ4nk7Wl0VLLAfOdSHwu7210N5fc5D7xvyIy1Fj5+6j0ltZ8 S6qa54nCSoxc2lMosDP0Nndp814fHgtZFGg/WwdHS9sqzZf3mgw/XyvffPUZzWtVF78H Mr0mX8mnbSbVLmrScKKMcIPSgwso2psD6tlJh9PzF8wqVvcPV3oKjZuuYP4h8d8cakyk z0Rg== MIME-Version: 1.0 X-Received: by 10.180.38.76 with SMTP id e12mr7915849wik.76.1424287821132; Wed, 18 Feb 2015 11:30:21 -0800 (PST) Received: by 10.194.154.229 with HTTP; Wed, 18 Feb 2015 11:30:21 -0800 (PST) In-Reply-To: References: Date: Wed, 18 Feb 2015 23:30:21 +0400 Message-ID: To: Nikita Popov Cc: Dmitry Stogov , Nikita Popov , PHP internals list Content-Type: multipart/alternative; boundary=e89a8f643340a2f97b050f61d9d6 Subject: Re: [PHP-DEV] [RFC][Discussion] Parser extension API From: lisachenko.it@gmail.com (Alexander Lisachenko) --e89a8f643340a2f97b050f61d9d6 Content-Type: text/plain; charset=UTF-8 > I'm okay with having stuff like ->getKindName() on the nodes, however I'd > still keep around the free-standing functions, because they can be used > without a node (i.e. you only need the kind AST_FOO and not an instantiated > node). I think that getting name of kind is useless without value of kind. According to the RFC, there is only one way from user land to get a kind of node: ask a parser for an AST, that will contain nodes. Is there any reason to do getKindName(1), where 1 - is just integer value. I can't see how it can be useful, this information is fully related to the node. I also don't see why we need ParserEngine::parse() instead of just a > (namespaced) parse() function. Not a fan of unnecessary wrapper classes. I think that PHP is ugly enough :) We should try to use namespaces and classes with methods to provide a better experience for user land developers. Classes allow for logical composition of common functionality, provides autocompletion in IDE and can be considered as step to standardization of core API. (Today I discussed this question with colleagues that will be great to have all system classes in Php namespace for PHP>=7.0) I know, that on engine level, classes aren't native, but you should think about how this feature will be used by developers. Because, creation of API is one-time process, but imagine how many times it will be used by developers. I think, it will be more polite to provide OO-code for modern API. What's the advantage of this? Most leaf nodes will be zval nodes and I feel > it would be rather inconvenient if they'd all have extra wrappers. Is there > some specific problem with including the values directly? Yes, reason here is the same as for `token_get_all()`. I hear so many WTFs when value can be either simple character or array. Much harder to work with inconsistent data and many libraries performs additional steps to provide better usability (see https://github.com/Andrewsville/PHP-Token-Reflection/blob/1c5ff91ee6877d1fb0f60fab3e3fc562bdb02684/TokenReflection/Stream/StreamBase.php#L100-L108 or https://github.com/lisachenko/go-aop-php/blob/3c381e243367096d47dc9676b3ad7445d7720ba9/src/Instrument/Transformer/MagicConstantTransformer.php#L117 ) So, each element should be represented as common node, this will simplify usage of API. --e89a8f643340a2f97b050f61d9d6--