Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92037 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95047 invoked from network); 31 Mar 2016 08:35:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2016 08:35:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 209.85.161.170 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 209.85.161.170 mail-yw0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:35142] helo=mail-yw0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/70-24828-231ECF65 for ; Thu, 31 Mar 2016 03:34:59 -0500 Received: by mail-yw0-f170.google.com with SMTP id g127so89106028ywf.2 for ; Thu, 31 Mar 2016 01:34:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pthreads-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=TwkQXo7gq/hDgogR0Ybe+FA62nClm4CpjuCXxtYsrNU=; b=t7rlBX8XMaKYKlmIX5MxIqeWozl0bXGmvZ9h5Dh9YHDHeNkOGzYQg7rp6W6xPmuzBh Esnz7xZ7AYtDLmDf8ZjIW05ORPMdA0LeHsf1VVsuViKqKnJZUoLajHurUnyCcLqvjViz HsWFsXcDImtOyyoBcG8qtvNZWwyLMtxEKnHrHH+P/DioDremEVgIG7EPynHvo8IOTu/D i2m258vV1AVSAqlgEhvXDKMiMcQ16YqveOK1t+y7cja8GO84dZMBPdSenYYAmS7txyl7 4aFAxV7k1jMlLmebGcYImwKcxEXO8WjNXUBBaYcp/Z+lpX1BU5EuFQh/qoYU7oe/BmRJ d1VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=TwkQXo7gq/hDgogR0Ybe+FA62nClm4CpjuCXxtYsrNU=; b=CMBY8F71DXtnM359NGdfDoNBybBYq6YotLwp096+YNqAeoSabeN966wEJP9ibOwxDF Hpfn4/j979fta1pi0RYhSbyP/C18Wnbui034f8PFdJyvzYTNPzkiyRrb9BAEu75etbM0 f/9K+rm0l4Tycm+hddtbGeV9NwGkfPmcGpbqc/kQymk9NixhC4BF2PmisoUy2HfEj5RV wkolKHrLMEdvPgjMbLCr3XkCPaKr5Vr+4aI2MQuv4Zt3pPeGPjC6fqzzUqKAs4wangNS 56MQXU84HpU8F76rCl9xritjTKW0NrIXNkzt2w0vxLJlw4hyZXvv1MP+E+3EbxJCtb3X 1yyw== X-Gm-Message-State: AD7BkJKJMx/smczrkBZJ7OiPFyk1O+jsGb5PGFxW0DJRPDLa18WpWYFnlWjVrvOVN6KNqN826q138YALyen+2w== MIME-Version: 1.0 X-Received: by 10.37.230.81 with SMTP id d78mr6676313ybh.127.1459413294638; Thu, 31 Mar 2016 01:34:54 -0700 (PDT) Received: by 10.129.39.9 with HTTP; Thu, 31 Mar 2016 01:34:54 -0700 (PDT) X-Originating-IP: [109.159.6.57] In-Reply-To: <56FC4ED6.6050701@telia.com> References: <1458153695.3969.16.camel@kuechenschabe> <3F.70.02405.6803BE65@pb1.pair.com> <56F01545.8080008@gmail.com> <56F14572.701@gmail.com> <56F15EF5.80006@telia.com> <56F16023.1010002@gmail.com> <56FC4ED6.6050701@telia.com> Date: Thu, 31 Mar 2016 09:34:54 +0100 Message-ID: To: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Cc: Dmitry Stogov , Phil Sturgeon , Krakjo , PHP internals Content-Type: multipart/alternative; boundary=94eb2c0b3532023680052f5423e9 Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: pthreads@pthreads.org (Joe Watkins) --94eb2c0b3532023680052f5423e9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Morning, > Given that public is implied for all properties above there > is a value in having the same rule for type. public $bar, int $foo; What does this mean? If it's not an error, what does this mean ? public $bar, int $foo, $qux; If it's an error, why is it an error ? Both of these examples are just as ambiguous as public int $foo, $bar, $qux; Access modifiers are assumed to apply to all declarations in a group, because that's what grouping is actually for. We don't need to make grouping about types, we need to make type declarations unambiguous. > Anyway, in Hack following syntax passes: https://3v4l.org/3tUu9 Hack does not consider types implicitly nullable. wrote: > Den 2016-03-30 kl. 05:16, skrev Joe Watkins: > >> Morning Dmitry, >> >> 1) static typed properties are prohibited. why? >>> >> Feels like that's a separate feature, static properties are as good as >> makes no difference, global variables. >> >> Instance properties, the engine has good control over their manipulation= , >> for static properties it doesn't, it's not impossible, but feels separat= e. >> > Good that it's clarified in the RFC since one could easily > believe that it's possible to set type for a static property. > >> >> 2) The handling of multiple properties in the same declaration statement >>> >> is inconsistent. >> >> This feels consistent to me .. in other languages where the type is >> required, it makes sense to assume the type is implied. >> >> In a language where the type is optional, public int $foo, $bar; feels >> ambiguous to me. >> > Given that public is implied for all properties above there > is a value in having the same rule for type. > >> >> 3) We already have nullable arguments without any special syntax. We >>> >> should reuse the similar approach for properties. >> >> Making properties implicitly nullable defeats the object of trying to >> provide type safety. >> >> Null is never a valid value for a typed property, if it were, you would >> never be sure of the type of variable you are getting, and would have to >> litter your code with is_null checks. >> > Maybe good to clarify difference towards default parameters? > Anyway, in Hack following syntax passes: https://3v4l.org/3tUu9 > >> >> I think it might be better to implicitly initialize them according to >>> >> type (if default value is not provided): bool by false, int by 0, double >> by >> 0.0, string by "" (interned), array by [] (immutable), objects by NULL >> (always nullable). >> >> Definitely not, lying about the default value isn't a good idea. >> >> There are times when 0 is as valid as 1, or any other value for an int. >> >> If you have declared that you know the type of the property, and you wri= te >> code that accesses that property before there is any possible chance you >> have set the property, that's a programming error. >> >> We should not hide that error with a default value, or by allowing the >> engine to return null. >> > Don't have a strong opinion on this one, can see both views. > Maybe a bit affected by programming in Java recently, having > a slightly more positive attitude towards default values ;-) > > Regards //Bj=C3=B6rn Larsson > > --94eb2c0b3532023680052f5423e9--