Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89397 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56668 invoked from network); 25 Nov 2015 00:31:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Nov 2015 00:31:56 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.215.49 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.215.49 mail-lf0-f49.google.com Received: from [209.85.215.49] ([209.85.215.49:36700] helo=mail-lf0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/1F-57156-A7105565 for ; Tue, 24 Nov 2015 19:31:55 -0500 Received: by lfs39 with SMTP id 39so40151838lfs.3 for ; Tue, 24 Nov 2015 16:31:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=dTWwll+2C2S4MwBeWqsOdLDVbRgO6wkwMnRG2ZRzCjc=; b=N8bRHdA3li9o9XmQOZ7jnFth9pWbe7XixMw7vkPzE7MQPnpWMevP6qtxelmy4/iJeo 7vLuYD7SxKyMKPVbvrwARt/sqBTFzDcvf62xJH3FdAmDLm54T3gPGvlqnql1HBpB0pYm HnMoQ3HmyK8RgtQDepYpWG3dnr5uj/RDQAOk18VKl5uGItEeTYGQPzQySRsD8Vau4Y6r gIUVZDM8AvPcNPVxuS3ljizmggY6dk1fBuj5imunsTPOC45yMRn7sZUvQS9Q1aXpZOZ4 wAaC78XeepRf6XurAyxXInxCaK0Dboeh8HvvzOuhCAqbeidyWwNit4jpnqkidypRBbUA Tjlg== 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:date :message-id:subject:from:to:cc:content-type; bh=dTWwll+2C2S4MwBeWqsOdLDVbRgO6wkwMnRG2ZRzCjc=; b=hXYLlL9p/UtQQo83NaVkvCEXjoln+QPbgRdNQR6znIGQu77Iltclp1c1XL4jqs+xV4 sDVzKzdM9hp8pTcPVHyU/otvXBORN15/K5HLg6CqiTMG1vX4H1PU6oNFUEFtYm71/5hH RJWkTgRBZxd4dLeE1zUNEYXuDKbA5x2OuWdSeWUBzBqydLNrCeyHnlncN4lSVslfUAL2 O+yqroP5KEarRwEqcgrL4DvS+1GXQNuaHokyrW6fE6SsjWBAcdnZExj73T+EjxKcQ/Fz w/HW1Zo8I+WRceuHhnopqGSjWBOB7muNqZeCqASGFxNVCXZdPqng5uA6Q+icUko9ALJF siIg== X-Gm-Message-State: ALoCoQmA37o02bBJ6kqFSrA4IARPrbVM0kDgbQhp/q2andijYYfrYAiK+i7VkqiokEt6G9BQgY6k MIME-Version: 1.0 X-Received: by 10.25.31.210 with SMTP id f201mr14533734lff.6.1448411511550; Tue, 24 Nov 2015 16:31:51 -0800 (PST) Sender: php@golemon.com Received: by 10.112.125.136 with HTTP; Tue, 24 Nov 2015 16:31:51 -0800 (PST) X-Originating-IP: [2620:10d:c090:180::1:2508] In-Reply-To: <5654B516.4020700@gmail.com> References: <5654B516.4020700@gmail.com> Date: Tue, 24 Nov 2015 16:31:51 -0800 X-Google-Sender-Auth: 04pfGP0bGDXv86xp77Ktv_XHrL4 Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Native Annotation Syntax From: pollita@php.net (Sara Golemon) On Tue, Nov 24, 2015 at 11:05 AM, Rowan Collins wrote: > At first sight, these seem like details which could be tweaked later, but > they make a difference to what syntax to standardise: is the annotation name > just a string, or a valid class name? is the value of the annotation just a > string, or a parseable PHP expression? is it more useful to use the de facto > existing syntax in DocBlocks, or to add a new keyword or operator? etc > If we're going to use something in the docblock, then I wouldn't want it parsed on compilation, but rather have it be an on-demand parse while reflecting. The reason being that there are plenty of docblock'd PHP libraries out there using invalid annotations because they're not running it through tools to tell them what they got wrong. Waiting till they've actually tried to examine it through reflection lets us throw an exception on code that cares about it rather than preventing code which ignores reflection from running. I, for one, am a fan of Java style annotations which allow a string name plus optional metadata. @@foo class Bar { @@Baz("something", 123, [ 'a', 'b', ''c']) public function qux() { ... } } Though the formality of having to define the annotation as an interface is a bit overkill for PHP, the same rules Hack uses would be clear and simple enough: <> class Bar { <> public function qux() { ... } } And no, I'm not picky about the parser symbol used... In fact, allowing an optional '//' prefix to annotations might be nice for compatibility. -Sara