Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90463 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37988 invoked from network); 10 Jan 2016 21:31:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jan 2016 21:31:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.172 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.192.172 mail-pf0-f172.google.com Received: from [209.85.192.172] ([209.85.192.172:34974] helo=mail-pf0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8A/A0-14657-1BDC2965 for ; Sun, 10 Jan 2016 16:31:30 -0500 Received: by mail-pf0-f172.google.com with SMTP id 65so34775572pff.2 for ; Sun, 10 Jan 2016 13:31:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=gMcz3B/HVYq+udXr+kyTTWWKI3+Gq7PSN0yLU1MVR7E=; b=MepWEoH8laFyp5plQsAFgUz7Z+3CeWC1IfNGWwoxDcJZkWBmKAWlHevJ+pzQiiZIa9 ooW82LLdburopHLjLqxd8UNxycHoPRw9F2yCspVhO9HUTz9SyHOwYAVv2gtc/IrIkAiL Sfm7FbDE3rjo3CLR9/+pNwaqTYrOQPDlBe3qTQIQV9pSKwdAoeRwsvt8srwqsua5Nh2p ntFOAFj5ZlbS4JwbJSuX5vORCoyjWtKbL0UtlRsvt7lo1yzCOf2hOjN+m0TpnfLL6ZNm ZKbMhn4cBjf/ZKGj3Li0ezygwf696X0re17n122qLvEwFsezOhK2HpfnujWPCWMlZVcZ 2pSA== X-Received: by 10.98.72.135 with SMTP id q7mr21334767pfi.151.1452461487141; Sun, 10 Jan 2016 13:31:27 -0800 (PST) Received: from ?IPv6:2602:304:cdc2:e5f0:55a0:5d7d:dcb9:2ea7? ([2602:304:cdc2:e5f0:55a0:5d7d:dcb9:2ea7]) by smtp.gmail.com with ESMTPSA id x18sm18352695pfa.65.2016.01.10.13.31.25 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 10 Jan 2016 13:31:26 -0800 (PST) To: Sara Golemon , PHP internals References: Message-ID: <5692CDAA.4020807@gmail.com> Date: Sun, 10 Jan 2016 13:31:22 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: [RFC] Normalize token_get_all() output (with flag) From: smalyshev@gmail.com (Stanislav Malyshev) Hi! >> A suggestion from a co-worker who's worried about seeing patterns like: >> >> case ($t['token']) { >> case T_PAAMAYIM_NEKUDOTAYIM: >> // do something >> break; >> case ord(';'): >> // do something else >> break; >> } What's wrong with this pattern? Looks pretty fine to me, clear what's going on. >> 2) Make the token field be the character value (for single-character >> tokens) instead of the ordinal. That would work too, but the side effect would be mixing types. It probably not too much trouble since tokens are numbered > 255, but it may have some unexpected effects that most of the tokens would match by == 0. Not sure if that's a problem. >> 3) Add an additional field such that you have Array ( ['id'] => 59, >> ['token'] => ';', ['text'] => ';', ['line'] => 1 ) 'id' would always >> be integer, while 'token' would be int or single-char. >> >> I don't like 3 as it's wasteful and needlessly duplicative. 1 feels a >> bit over-engineered and actually hurts readability. 2 feels like a Agree on both 1 and 3. -- Stas Malyshev smalyshev@gmail.com