Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92500 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45754 invoked from network); 19 Apr 2016 22:10:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Apr 2016 22:10:20 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.46 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.215.46 mail-lf0-f46.google.com Received: from [209.85.215.46] ([209.85.215.46:34290] helo=mail-lf0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/BA-22821-ACCA6175 for ; Tue, 19 Apr 2016 18:10:18 -0400 Received: by mail-lf0-f46.google.com with SMTP id j11so30001484lfb.1 for ; Tue, 19 Apr 2016 15:10:18 -0700 (PDT) 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; bh=LZEDVsLdrKbrLwB6Y1DyiyuFYEIGNoe/72kEH/WFNrs=; b=twQ+4BGEB7fzLfF9ytt3n0+72i+ZxR7vRUf0mWBxoqZuOF+EGibEJfRVScd/HxWn6a U619tDqbTzDnxcj/Khe6TO99fdeY/+X4OvfEmGUNLuvCD5xx1RajXm2Kx2VoIVeaL5fR tcSl9eIWNs2+wTcALvd/zuZO7fzeHJnermkI8kMDq6KS6MX1TD1sAmpKTZiSVMJkGljJ DxW8J8v90eisNF1x4QMMFzg5TREdxNGJ0SVawHamwDsZUBAoEvj6LuEFZFdXP4DQlgw5 RTUPWrRXPys8eBf34PoXnst7NYFLYHVI8OUWXxuyjqTE77E0hSy3M8kzCivasyXNBV1+ 3N3w== 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:from:date :message-id:subject:to:cc; bh=LZEDVsLdrKbrLwB6Y1DyiyuFYEIGNoe/72kEH/WFNrs=; b=WZkCxxlBJHzKCFPIslBZ0D8useMkHrYBs+z0RtTvW7aq5mZKFDr0urltD6xdui9NcR Zm2qAtSK1IKwtZI4nSbI1OkBKBAF42qOJ7yxhXhNWI0gbKyqRbFgVinLk/tiWC3OoPPB qSxEz1FQkAS1tB7UDu+9QtJVUbAKcq1GcptpOfIPz1lp/S6QksoFPFVUYsZ3GYsIPK2k 5xCV9XLfwykA0CWWdMGCMQDodXQcCD/LFY1KYKmInl+Kf1S1L7kpM1TjAWOHlJP/RPuq tQNPZ01lXVXfhxEm1RZfnIgzkSh6iBbAJi/7y6wcw5BXp5onfb+k1nux/xrYlaHX6ojC 0I8A== X-Gm-Message-State: AOPr4FWUJ/k+yHqjqVGIEQRqOWS/Ro0/EVZxr2yHxhgjiOdFX8KRkbPCw+S+MxSBNdxpc/apK/dUuJFol/2/mw== X-Received: by 10.25.206.207 with SMTP id e198mr2116220lfg.97.1461103814675; Tue, 19 Apr 2016 15:10:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.126.67 with HTTP; Tue, 19 Apr 2016 15:09:54 -0700 (PDT) In-Reply-To: References: <570E99AC.3090804@fleshgrinder.com> <570EA5EB.8090501@fleshgrinder.com> <570EAB0D.6080706@gmail.com> <570EB67E.8010908@garfieldtech.com> <5B147E88-CC0A-4CBC-A49D-C7FE3BF557C0@zend.com> <6F.C3.12455.94C5F075@pb1.pair.com> <20160414094440.GF19347@phcomp.co.uk> <570FD94F.90703@fleshgrinder.com> <570FE8A9.4020809@gmail.com> <20.53.29891.17401175@pb1.pair.com> <57110BCD.5030009@garfieldtech.com> <571124C2.9040606@gmx.de> <57112F31.8070209@garfieldtech.com> <57167C35.8080601@gmail.com> <57168FCC.7000507@garfieldtech.com> Date: Wed, 20 Apr 2016 00:09:54 +0200 Message-ID: To: Zeev Suraski Cc: Levi Morrison , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11412f56da94bb0530ddbddd Subject: Re: [PHP-DEV] Re: Improving PHP's type system From: ocramius@gmail.com (Marco Pivetta) --001a11412f56da94bb0530ddbddd Content-Type: text/plain; charset=UTF-8 On 19 April 2016 at 23:47, Zeev Suraski wrote: > I fail to see how adding C++ templates to PHP takes it to the next level > in anything but the complexity scale. Not having them is not preventing > anybody from doing anything today. Sure, a bunch of frameworks would adopt > them once they become available - but it will not enable them to do things > that are radically different from what they're doing today. > And the fact that you fail to see it is why you don't see any advantages, but that's because you are likely unfamiliar with most recent tooling around static introspection. Any reflector-based system, such as a serializer, an ORM or just a dependency injection or configuration loader would be able to do operations in a much more precise and less complex way. In Doctrine ORM, having a way to know that a field or parameter is a `string | null` or a `int | float` may be the difference between knowing what kind of column definition is needed for a field at DB level, without even need for defining manual mappings. Having a configuration system that expects to call setters with specific parameter types can allow the configuration system to validate the given data upfront, providing meaningful exceptions to the user, without having to write an entire separate config specification. Having a serializer that expects certain types of data allows rejecting any kind of value that is possibly insecure, and would cause a RCE vulnerability by unserializing a value into something with a malicious `__wakeup` in it. Etc etc. In general, improving the type system provides a much more interesting and practical playground for any kind of tool that would rely on static introspection: IDEs, reflectors, code generators, code inliners, documentation generators. The runtime part of this is just a tiny fraction of what is interesting about improving the type system at all. Hope that gives some useful context, in order to see where this would actually be useful. Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a11412f56da94bb0530ddbddd--