Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58824 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5712 invoked from network); 9 Mar 2012 15:20:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2012 15:20:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=linepogl@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=linepogl@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.170 as permitted sender) X-PHP-List-Original-Sender: linepogl@gmail.com X-Host-Fingerprint: 209.85.213.170 mail-yx0-f170.google.com Received: from [209.85.213.170] ([209.85.213.170:41860] helo=mail-yx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 65/70-02228-5CF1A5F4 for ; Fri, 09 Mar 2012 10:20:37 -0500 Received: by yenl5 with SMTP id l5so1027090yen.29 for ; Fri, 09 Mar 2012 07:20:34 -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=fbnYTom4z5wab3gEAQE5E245BCmyzUWBToEnA4zVS3g=; b=snWsa5qGJszmJZD5I8BEFRrJ6s77m+UDfTOZJwLkaLfxbvthQzhalxhozZTRhAbLGy lcdOx98USwzopeG9cbgpc3WaHYIwhKENnlbLNb3hVZfWsIfCRJo52E4cuG0XvU+Hr2ks Ko51h4c6U5JXbJDWqn8CNOAaGEMfXa/rPtOeP8CldhDd5ugxdNgEnDYDFVLAVpriC6Ey 80YN9vcRJb7GLM5brYO+mz1GbV1oqv46d2kEKIVWK/0aR25aDdgQw941JRarm5FO8tHs 0RT+3B9xRzBgNmeUqPvaBIjhabw+1b+7f4n+3ACagMrckvnaol/eigL9s0Em4W6p5ueM z0NA== Received: by 10.236.76.198 with SMTP id b46mr2742557yhe.25.1331306434176; Fri, 09 Mar 2012 07:20:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.146.144.35 with HTTP; Fri, 9 Mar 2012 07:20:14 -0800 (PST) In-Reply-To: References: Date: Fri, 9 Mar 2012 16:20:14 +0100 Message-ID: To: Simon Schick Cc: Anthony Ferrara , internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf300fb3a718a74304bad0ef02 Subject: Re: [PHP-DEV] [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters From: linepogl@gmail.com (Lazare Inepologlou) --20cf300fb3a718a74304bad0ef02 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > What the current idea would be is an implicit casting (as I understood it right). Yes, exactly. > This won't make it easy passing a variable as reference. Type casting combined with passing by reference is problematic in many ways. Just an example: fuction foo( string & $buffer) { ... } foo( $my_buffer ); Here, $my_buffer has just been declared, so it is null. Should this be an error? I don't know! So, I think that that passing by reference should not be (immediately) supported. Lazare INEPOLOGLOU Ing=C3=A9nieur Logiciel 2012/3/9 Simon Schick > 2012/3/9 Lazare Inepologlou > > > > Yes, like that, only better. Since automatic type casting is central in > > PHP, as this is evident after all this discussion, I believe that it > > should > > be better supported. There are two thinks that I would like to see here= : > > > > 1. No more magic methods, please. > > 2. It should cover (eventually) casting to and from any type. > > > > :-) > > > > Lazare INEPOLOGLOU > > Ing=C3=A9nieur Logiciel > > > > Hi, Lazare > > As you mentioned it in another thread, I like the idea of C# you describe= d > ... > Draw a line between explicit and implicit casting. > > What the current idea would be is an implicit casting (as I understood > it right). > Let me just repeat your examples: > > 2012/3/7 Lazare Inepologlou > > function test_float( float test ) { ... } > > test_float( 1.0 ); // ok > > test_float( 1 ); // implicit int to float cast, ok > > > > function test_array( array test ) { ... } > > test_array( array() ); // ok > > test_array( 1 ); // no implicit int to array cast, error! > > test_array( (array)1 ); // explicit int to array cast, ok > > An explicit type-cast should be always possible and try to get the > very last bit of useful information out of the given bunch. Here it > makes sense to have magic functions for integer, float, string etc. > > But as we're here talking about an implicit casting when passing a > class to a function, I don't like the idea of calling the > magic-functions if you paste a class in here as it changes the content > of the variable. This won't make it easy passing a variable as > reference. If you just switch to another type, you can afterwards do > whatever you was able to do before. > > Bye > Simon > --20cf300fb3a718a74304bad0ef02--