Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58619 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59565 invoked from network); 5 Mar 2012 19:38:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2012 19:38:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=admacedo@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=admacedo@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: admacedo@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gy0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:47734] helo=mail-gy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3F/3C-35539-346155F4 for ; Mon, 05 Mar 2012 14:38:44 -0500 Received: by ghbg2 with SMTP id g2so2099644ghb.29 for ; Mon, 05 Mar 2012 11:38:41 -0800 (PST) Received-SPF: pass (google.com: domain of admacedo@gmail.com designates 10.236.186.1 as permitted sender) client-ip=10.236.186.1; Authentication-Results: mr.google.com; spf=pass (google.com: domain of admacedo@gmail.com designates 10.236.186.1 as permitted sender) smtp.mail=admacedo@gmail.com; dkim=pass header.i=admacedo@gmail.com Received: from mr.google.com ([10.236.186.1]) by 10.236.186.1 with SMTP id v1mr29496572yhm.4.1330976321485 (num_hops = 1); Mon, 05 Mar 2012 11:38:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=AUs4p+Pj/9hOvHIfZXJqI7bdhYXiE0gpz12WKfvsRcU=; b=kUhr7q/lVQKo8NXbhIWjhzlPtoFvQt1q07cXa+T8hM7jgwf4HOkycDLUQtMQPUvi1y 9TYemxJuLwT/He+tW9F2gEJ9Ee+PgXTUoY4ac6qAiJMKu3gAkhRTKn0D7HA6sovNL2e+ 2xkXyIXMvbMPWwspBaYcSzC/51oowkTc3S6ZgrtDPJXP7BIs6JuZt7uAonken2bTSqDz pvmGKycTF7tUrwdY7rU7IDI0+mwsM3zxG+kBbpF8+mkByMfUL2QlBebYm5crdJNx9PGq env0oTIlbUBkpRm91Ys3RAwfkusRezs0cy4VsY0QtDhtfrUB5frlpXlvXDciLAmo/KQ7 p5+g== Received: by 10.236.186.1 with SMTP id v1mr23301275yhm.4.1330976321277; Mon, 05 Mar 2012 11:38:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.180.70 with HTTP; Mon, 5 Mar 2012 11:38:01 -0800 (PST) In-Reply-To: References: Date: Mon, 5 Mar 2012 19:38:01 +0000 Message-ID: To: Lazare Inepologlou Cc: Anthony Ferrara , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [POC Patch] Scalar Type Hinting/Casting - Proof Of Concept From: admacedo@gmail.com (Daniel Macedo) Hi Lazare, I'm a bit divided on your proposal. On one hand I kind of like the simplicity of the syntax and the basic idea behind it: > (int?) $x > > which should be strictly translated to the following, without any way to > change that behavior by any type casting overload system: > > is_null($x) ? null : (int)$x > But on the other hand, I'm not sure you should mix type casting and the short if syntax (which is clearly what inspired the question mark there). This sort of makes me think you're really turning an (int) type casting, into more of a (mixed) type casting... I don't really like that! :) Therefore I'm divided into thinking this is a cool idea, or if I'd get so confused about this I would use it as much as the short if syntax: $var = @$_GET['var'] ?: 'default'; (Which is never, btw!) How about allowing *several entries* per type cast (since spaces are allowed inside casts anyway, but could also be a semicolon or something): $int_or_null = (int unset) $x; This could be usefull for other instances as (string null) or (bool null) as well... Your thoughts? Best regards, ~ Daniel Macedo