Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91426 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28312 invoked from network); 25 Feb 2016 22:44:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2016 22:44:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=adam@adamharvey.name; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=adam@adamharvey.name; sender-id=pass Received-SPF: pass (pb1.pair.com: domain adamharvey.name designates 209.85.215.43 as permitted sender) X-PHP-List-Original-Sender: adam@adamharvey.name X-Host-Fingerprint: 209.85.215.43 mail-lf0-f43.google.com Received: from [209.85.215.43] ([209.85.215.43:36642] helo=mail-lf0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/A8-11730-6C38FC65 for ; Thu, 25 Feb 2016 17:44:22 -0500 Received: by mail-lf0-f43.google.com with SMTP id 78so42621384lfy.3 for ; Thu, 25 Feb 2016 14:44:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adamharvey.name; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=Uyu19tEdK3vQrFitgIC/shtgwSYZASUm44qwMevtmN4=; b=wYDaezHS0yhye2YjbbrrOOJ2FDvWBqv0Yb8sbzd18uZgWRgMhhmbcM9d0p4x8UzVvN D4OjdVfeclA38MTPqHXbyDSy/qRlpXUO9jsDDnJwU5Q2Dz1tyFHR6ni/6qrXLQ33rpZp ATBoRJyUT+e7Lld1TafY7jTGoFAEAlT0kG+qs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-type; bh=Uyu19tEdK3vQrFitgIC/shtgwSYZASUm44qwMevtmN4=; b=a8Oyjc0cd0JVsTm1/xThj/3ph53cqsBpn0jTJ4VX9vpO5BfCayZDtaabODTdHLg20b nrw6KQrNSXbQp4mBNgXL2NFOqXiRnLczSmsp4ge45HPr20sBXNhEYPlw9bvSb7M92t4f rpA68RGSHqaEIGPZU8SiSk80wTa8XJlUpaBU+N3bTEW+clAyZpvx/h+7QcebnX7LZw+P Dwhm3Fk3sQGQAxbPBuwdt6mRRpunLL+TAav4yfWD6fU7dHZaDdFulEkR8xpsCaIuwueT 01+ABlRz/X2Ua6+9J6MjFJH3B5mWtwg6xAetZapchepV8qpItbj5xRCd0pMt5Aue3GVG l25Q== X-Gm-Message-State: AG10YOTr9wOqJ6eacAQj0/DWlloFDsrnerp2aT7Y2Y0L2eO3MDMjgR0wBxvSFpvQx7gbK2s/K0Ig7R8PPUNexg== X-Received: by 10.25.4.7 with SMTP id 7mr17235990lfe.45.1456440259559; Thu, 25 Feb 2016 14:44:19 -0800 (PST) MIME-Version: 1.0 Sender: adam@adamharvey.name Received: by 10.25.216.74 with HTTP; Thu, 25 Feb 2016 14:43:59 -0800 (PST) In-Reply-To: References: Date: Thu, 25 Feb 2016 14:43:59 -0800 X-Google-Sender-Auth: 126Ey0OcfEKn2kqmKtYs6WffZ6o Message-ID: To: Dan Ackroyd Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Callable constructors From: aharvey@php.net (Adam Harvey) On 25 February 2016 at 14:19, Dan Ackroyd wrote: > On 25 February 2016 at 18:16, Adam Harvey wrote: >> >> am I right >> that this is equivalent to the following? >> >>$injector->delegate('FooInterface', function (...$args) { return new > FooImplementation(...$args); }); > > Nope. > > The vital part you missed is that with the original function, all of > the parameters (aka dependencies of the class) can be found through > reflection, and so can be created by the injector as needed. By using > function (...$args){} - all of the parameter information is lost, and > so isn't usable by an autowiring-injector. OK, I understand that now. Thanks. Why is having a special syntax that is considered callable and conflates instantiation and method calls (which are ultimately separate things) better than having the injector accept a class name and use reflection as required to instantiate that? >> "I only skimmed the RFC" > > I find this very dissapointing. Conversations are far more productive > if people have read the whole of a proposal before deciding how they > feel about it and giving feedback. To be clear: I did read the entire RFC, just quickly. Since it seemed an obvious question to me (and apparently not just me, based on /r/php), and didn't seem to be addressed that I could see, I thought it was better to just ask it rather than stay silent and either ask it several days later or vote -1 without explanation. > In particular reading the sections "Can't be used as strings in class > properties" and "Can't be used in string based configuration" would > give examples where the RFC is of benefit in a way that is not related > to DIC libraries. Honestly, I still don't find either of them particularly persuasive, for the same reasons as the aforementioned DIC example. They're trivially special cased without muddying instantiation and method calls. Hence my "are there analogues for this elsewhere" question. Adam