Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63959 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88187 invoked from network); 17 Nov 2012 19:16:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2012 19:16:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:63595] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9C/DB-08060-592E7A05 for ; Sat, 17 Nov 2012 14:16:38 -0500 Received: by mail-lb0-f170.google.com with SMTP id j14so3018814lbo.29 for ; Sat, 17 Nov 2012 11:16:35 -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=ReM6/7PvCxXgJCn0gylbtmt37x2sqn/6VrzpU0tspMM=; b=Wz7kAx+Z2Rr9viBMBHN5VFM5cXJB614BRm8olQr/ODpTE0xZLBCuZ4Cbs3uKxAF/0a U7O71q2QF1EBpiEsu8Seyx9ipkSSbohOp5zm68TriNa7R/UtMYQZfqPMsQLuUtNQbT9U Gr6vSzqyFCjnADf+3kxsy6IaXq8L55jutV58zdikY4j5Dr+pSbeL2Eby/Za2dAojRiFO L3wKIGDwqqn/BrYOoXi+4EgOmUFD2jpSn2hukUYG2MCZIQ9xVrAWaBtiYxWXGuv3z0Sm AqZZ8GQXOlXUyzOZ6+zMZpicKY4dsdHnieXgwRJUvMlwD3pbfSF9ghq9cgx6YfgsFmIj yvmA== MIME-Version: 1.0 Received: by 10.152.108.37 with SMTP id hh5mr7519277lab.52.1353179794870; Sat, 17 Nov 2012 11:16:34 -0800 (PST) Received: by 10.112.36.39 with HTTP; Sat, 17 Nov 2012 11:16:34 -0800 (PST) In-Reply-To: References: Date: Sat, 17 Nov 2012 12:16:34 -0700 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Functions for getting long / double from zval with casts From: morrison.levi@gmail.com (Levi Morrison) On Sat, Nov 17, 2012 at 8:15 AM, Nikita Popov wrote: > Hi internals! > > It happens quite often that you need to extract an integer from a zval and > you also want it to work for integers in strings, etc. In order to do so > you currently have to cast the zval to integer. This is always rather > complicated because you often don't want to actually change the passed > zval. So you end up allocating / separating zvals and stuff like that. And > I'm always confused just which exactly of the 50 different ways to cast a > zval one should use in a particular situation. > > What I'd like to propose is a set of two new functions, which castingly get > an integer or a float from a zval. The functions could look like this: > > long zval_get_long_with_cast(zval *value) > double zval_get_double_with_cast(zval *value) > > What do you think? > > Nikita I'm new to internals but this is one thing I've dealt with. I would certain vote for it. Question: how does this handle objects, arrays and resources? For a particular use-case I need something that works on integers and integers in strings only.