Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64835 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50601 invoked from network); 10 Jan 2013 23:33:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jan 2013 23:33:23 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.48 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.215.48 mail-la0-f48.google.com Received: from [209.85.215.48] ([209.85.215.48:59181] helo=mail-la0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/91-02684-3CF4FE05 for ; Thu, 10 Jan 2013 18:33:23 -0500 Received: by mail-la0-f48.google.com with SMTP id ej20so1201915lab.21 for ; Thu, 10 Jan 2013 15:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=CtkxO3uYAdGW2GQWbFucqNZd9F+HVHvsCZZ0jVA1KjE=; b=R+YtS/XQb7e/HSEzeuSAKRwPejuHmI6Z5XAmyG31oYJCQdu3MlX2UX6nVWqCcXnrFz J+v3gd2o+CHt+f1k49GJDoZYh89mPmV5MHvOdEmoeUdMp/jW6fiY96QjnCTjjst3W1Ei ECKiHeU5t9/mQx+5f5HT3e3Pf/BoelucLuY9aszAFI4WfibinWFTOdUlPY71fwbJS40j WEWw7/KE/LRL7IfQp9MRjajztmTU/3Lm+WXYxYFgyrwKCBIQSeRHFSYhQJA0FXbmlQdr sJ8RB7WDPqudeun7YVUwLA+zPIokQY6d9884EG4BL9HGF2IQLFJPaV7eoVAiQf2gAM34 5rzg== MIME-Version: 1.0 Received: by 10.152.47.75 with SMTP id b11mr69460102lan.14.1357860800402; Thu, 10 Jan 2013 15:33:20 -0800 (PST) Received: by 10.112.4.168 with HTTP; Thu, 10 Jan 2013 15:33:20 -0800 (PST) In-Reply-To: <50EF3C9C.3020701@sugarcrm.com> References: <4ED7146272E04A47B986ED49E771E347BB3D6ABCB3@Ikarus.ameusgmbh.intern> <50EC5F8F.8010703@mrclay.org> <50EF3C9C.3020701@sugarcrm.com> Date: Fri, 11 Jan 2013 00:33:20 +0100 Message-ID: To: Stas Malyshev Cc: PHP internals Content-Type: multipart/alternative; boundary=bcaec55404a2a995ee04d2f79a5a Subject: Re: [PHP-DEV] [RFC] Alternative typehinting syntax for accessors From: nikita.ppv@gmail.com (Nikita Popov) --bcaec55404a2a995ee04d2f79a5a Content-Type: text/plain; charset=ISO-8859-1 On Thu, Jan 10, 2013 at 11:11 PM, Stas Malyshev wrote: > Hi! > > The proposal is pretty clear, but could you explain this part: > > The current accessors proposal will need special handling of the > typehint in any case (it can't be handled as a normal method typehint). > > What special handling is required? > I have written that in anticipation of a rewrite of the current automatic accessor implementation. Currently it creates a string of PHP code and compiles it as the method body. We were planning to replace this with handling directly in the object handlers (because automatic accessors just need to use the "normal" property code rather than the accessor one). In this case we'd have to handle the typehint explicitly. But I'm not sure whether we will still do this, so I'm not sure whether that statement in the RFC is still true. On this subject, are you (personally) okay with the current approach for creating automatic accessors (i.e. create PHP code string and compile)? > One question that still needs to be discussed is what syntax regarding > > parentheses we want to use if this makes it. Currently both set { } and > > set($foo) { } style accessors are supported. Do we want to keep those two > > with the new syntax? > > Within this context, I'd prefer getting rid of set {} and only have > set($param) {}. You don't save that much typing and you do it at the > cost of additional obscurity and complexity - now every developer and > every tool that deals with it needs to remember there's hidden $value > parameter. IMHO not worth it. I can see what "get;" gives you - you can > say "just do the natural thing". But if you start writing code anyway - > i.e. if you do {} - then I think it should look like a real function. > Just to make sure I got it all right, you are suggesting: * Parentheses must be used on all accessors, so it's set($value) {} and get() {} and isset() {} and unset() {} and something like get {} is not possible? * Automatic accessors don't have parentheses so they are just set; get; isset; unset; Is that right? If so, then I think it's a reasonable approach. Nikita --bcaec55404a2a995ee04d2f79a5a--