Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92939 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65108 invoked from network); 29 Apr 2016 15:44:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2016 15:44:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.41 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.41 mail-wm0-f41.google.com Received: from [74.125.82.41] ([74.125.82.41:37150] helo=mail-wm0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/DC-26386-97183275 for ; Fri, 29 Apr 2016 11:44:58 -0400 Received: by mail-wm0-f41.google.com with SMTP id a17so43070710wme.0 for ; Fri, 29 Apr 2016 08:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=RWmgAJjR+JM6U3cFpF+2kdU/IJ7e392r9Rixe/f8wNY=; b=lhArqrQ5A3WR9n718qJtK86y771ytMk0KjXO+5xec61hp7Eh4D282ghz2ntQRzpzPa cgt2TPQUX9h29Tc1RwppwqzUTHeNn8f2iD+xvF2XXsNTqTyyPqn8u3qLN4I9geHBhMPL vCQsNM+FTnfKq34XFXY+y6Dz+FokX4M9VZ0DuUqxtGEv5BzmPBb/AUZeJs99y+Jpi9BW EMgksGn4aeKgyDNtZvDHHUizxXheWzSJOaGdJB9Jdo+2dWjqo7gxGjgPBHkudpN80tLQ Ph2Bu/vZ7G9Edkrj7Oex8fPzt+A6Lwmrhx9EGRnduJmMLPCsj9zDZl7kO1xkhUhgT6ZA u7uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=RWmgAJjR+JM6U3cFpF+2kdU/IJ7e392r9Rixe/f8wNY=; b=RySmHptvvvei4Bo14trslLcuY+VYD0RqLRkL6wRCY4+3bYaGBtPvXxVWiKdw1v7S4l BwaRadldLevZCoqE/XJq6qydwFiE27qjvMAfo8PsMdF3whTwja6uJ2bXrsHPOny54zOZ hky5CtkXDCDz3/zvKSUrCnhZMpptw+EnPMUp3K70iIvib6SfZdlGGaasbE3CFK6Pf491 v+Wtcl7xLASqWkxGu0Gnj9i8oZGEklOleq2pBL84IgjXm+Fy1xlNpcxgtmxPUaH4guLD DQmWVe3j70tyXmiKope3qW0b7BZF2z2BqaY2Mwtod6tXuL3YCwFwKjjBRx2t+/MvbBUF Mebw== X-Gm-Message-State: AOPr4FU16Iq+GPePAjw3h2ei+pewEfyHe0smrcLhinQ//IvPAcMbjkLlBvkXx9GPxwe3EA== X-Received: by 10.28.158.15 with SMTP id h15mr4780783wme.35.1461944695371; Fri, 29 Apr 2016 08:44:55 -0700 (PDT) Received: from [192.168.0.82] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id l124sm3848505wmf.11.2016.04.29.08.44.54 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 29 Apr 2016 08:44:54 -0700 (PDT) To: internals@lists.php.net References: <571E64A2.2040505@gmail.com> <5720A6B4.4000307@lsces.co.uk> <5721B9DD.3050300@lsces.co.uk> <57231ADD.9040006@lsces.co.uk> <572326A3.7000809@lsces.co.uk> <57234D3D.1070602@lsces.co.uk> <79c9df57-ee45-f415-3172-95f8229bbece@gmail.com> <57235F20.5080707@lsces.co.uk> <43b9c67f-3ec7-bacc-2608-552abbd1a3fa@gmail.com> <57237B36.1070301@lsces.co.uk> Message-ID: <0d71618b-2ffa-7273-f9b9-aeabc35f4211@gmail.com> Date: Fri, 29 Apr 2016 16:42:30 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <57237B36.1070301@lsces.co.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP Attributes -> docBloc alternatives ... From: rowan.collins@gmail.com (Rowan Collins) Hi Lester, Lester Caine wrote on 29/04/2016 16:18: > I think that is part of the problem here. IDE's are currently making > quite good use of existing annotation text, but if they have to be > switched to modes where some other option takes priority then once again > all the code has to be reworked ... which is where I'm stuck at the moment. To be absolutely 100% clear, the attributes / annotations being discussed are NOT for use in documentation, they are NOT for use by IDEs, they are for use AT RUNTIME, by libraries which want to programmatically access them INSIDE PHP ITSELF. And if your code has no machine-readable annotations, I can virtually guarantee that you won't need to make a single change to your docblocks for your IDEs to carry on using them in exactly the way they're using them now. Of course, > As with 'strict typing' we add different styles of working which in some > longer term world may be an elegant solution but short term just creates > an annoying different way of doing a bit of the job? To an extent, I agree with this. Most modern programming language features are just sugar on top of more general functionality. But again, let's be clear: the functionality this is duplicating is not docblocks, it is executable code. So an imaginary attribute "<)>>" above a function might replace the code "if ( $a < 42 ) { throw new Exception; }" inside the function. There is some merit to saying that annotations already de facto exist inside docblocks, but that discussion has been had many times, and there is a brief summary in the current RFC: https://wiki.php.net/rfc/attributes#criticism_and_alternative_approach The most compelling argument to me is that since these aren't standardised, a lot of incompatible syntax exists out there that the parser would have to cope with (or force people to rewrite). > The comments go hand in hand with the validation so > why not keep them together? This is true of any code. If I write "if ( $foo < 42 )", I might put a comment next to it, but I wouldn't put the if statement in the comment. So it would be with attributes/annotations: you would write the code that means something to the engine, and then you would put a comment next to it. /** * @test($a < 42) Must not reach The Answer */ function foo($a) { ... } vs function foo($a) { if ( $a < 42 ) { throw new Exception; } // Must not reach The Answer ... } vs <> // Must not reach The Answer function foo($a) { ... } All of these examples have a mixture of code and comments, positioned next to each other, but nonetheless separate. Regards, -- Rowan Collins [IMSoP]