Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94288 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94973 invoked from network); 27 Jun 2016 18:37:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2016 18:37:05 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.213.41 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.213.41 mail-vk0-f41.google.com Received: from [209.85.213.41] ([209.85.213.41:35009] helo=mail-vk0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/E8-40393-15271775 for ; Mon, 27 Jun 2016 14:37:05 -0400 Received: by mail-vk0-f41.google.com with SMTP id j2so243634797vkg.2 for ; Mon, 27 Jun 2016 11:37:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=+1c4kVaDEgwAicpp26230O9vzULzX06dIaCcxEL82jE=; b=K8tl9baBCjIsieaxsie+uKENcm+cTrJ+Dirk1yBhjzPXEWXXk48W/uY2bwADfy3PXI yw561RSk2T83JplkQqtFz0EmaurmjpF0Ca3h+fYcRZk7Q1KuxxvUPEva4YOYeJP/R4gr Mi8rFoL5qVRxD/ek7quXbHVdv5/wmZiTZUZUdopCDXrA1PV3o6D+va+hR4AbX01tgW7X Zjo8A9k0v44Q2yfkuqTTgVr/mbHFVASv8jzhPIwMmtnnoMNDuA3Vyg7UoevKWlJmT4Gz Mid08Ib/iHFTww7ccOY7wQXmiPQ4Terkf0uLhegC6KLJ5Y//p+amaosGHsM8MawBEsnS JpoQ== 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; bh=+1c4kVaDEgwAicpp26230O9vzULzX06dIaCcxEL82jE=; b=dQ5o4oH6jXJb2wLomYcahBo875Q+idZeWYDvLhZp0MwUm3TWDFUXD40ASbjMD4Js8v zhQWWiEU8JWuwLZjvp9r42SvuwfCbbj7pnlsM6eTibGm5tR0G3jqxrbonyno9UqUiUmp UXWS2CFFD9a//LyRio4y0aZaZO1Z94eg8dgpyj8SLRdmvur+jEu+G/ReTvdvxvzteKd0 odsLgUQh4FR77Yoqgt18882D3nNEW3G1kztiW3Sixa/VhOf3nyvsXucTMvsTSHayo0U8 N04+BpiwK3FJPMBKMUr8uT/hPFLxDX2JL6LlhInBFJsV+DYAM5AlD7g+1YZ7ck1ByjI4 bqng== X-Gm-Message-State: ALyK8tKht1fDn1fOyB66kUxRwJwy61fUtYvhdRGNz2BJHPMwGBz7VBJ1LNsqFJJLIk0X7lVwRHEJB1mEN0zEGA== X-Received: by 10.159.35.72 with SMTP id 66mr9388687uae.55.1467052622316; Mon, 27 Jun 2016 11:37:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.88.148 with HTTP; Mon, 27 Jun 2016 11:37:01 -0700 (PDT) In-Reply-To: <211db59e-9c22-6df4-1f72-66ebbc5095bd@fleshgrinder.com> References: <211db59e-9c22-6df4-1f72-66ebbc5095bd@fleshgrinder.com> Date: Mon, 27 Jun 2016 20:37:01 +0200 Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Simple Annotations From: rasmus@mindplay.dk (Rasmus Schultz) Tonight I started trying to write a proposal for even more simplified annotations, e.g. something simple enough that it cannot result in fatal errors. I eventually gave up, and here's why. Essentially, if you have to restrict yourself to things that cannot under any circumstances error out, the only things you can use are constant scalar values - even constant scalar expressions could not be allowed, because even those could error when CONST_NAME or Class::CONST_NAME aren't defined. So, in a nutshell, what you're saying (Richard) is that annotations can only consist of scalar values, and possibly arrays of values? (and I don't even see your gist doing that - it's just invoking closures, as far as I can tell, and any of those could error, or not?) So, regardless of syntax, literally the only annotation data allowed would be blatantly simple things like: ["max_length" => 20] ["data_type" => "int"] Or in other words, constant arrays, int, string, float and bool values. Nothing else. Nothing can depend on any kind of external symbol (class names, constants, etc.) since any such reference can cause an error. No static analysis or type-checking of any kind can ever be performed - no assertions or declarations can be made about the shape or types of metadata, at all. The problem is, that's simply not useful. It's also not very different from what we have today with php-doc blocks - the only real difference is we can check array nesting and int, string, float and bool syntax, e.g. nothing really useful or important. In other words, this would be a very slight improvement on syntax - nothing that actually amounts to any kind of functionality. If we were to ship a feature like that, what would happen is precisely the same thing that happened with php-doc blocks: the real work will be done in userland (and likely dominated by one library), there will be no IDE support (except proprietary support for that one dominating library), no useful offline static analysis tools. At the end of the day, what we end up with will have all of the same issues we have with php-doc blocks and existing libraries. I don't understand how such a feature would be useful to anybody? I especially don't understand why you want a language feature that isn't allowed to reference external symbols - e.g. isn't allowed to have any kind of relationship with anything declared in userland. It seems to me a peculiar, arbitrary and unrealistic restriction to put on annotations. It's going to have no immediate usefulness, and mapping the data to objects is going to happen in userland, just as it does today. I'd like to work on this proposal, but I feel that you're giving me nothing to work with here. On Mon, May 16, 2016 at 12:38 PM, Fleshgrinder wrote: > On 5/13/2016 2:11 PM, Rasmus Schultz wrote: >> Dear Internals, >> >> I'm announcing a simplified RFC for annotations: >> >> https://wiki.php.net/rfc/simple-annotations >> > > -1 again, I am sorry. > > The problem is that an annotation by definition is just meta-data. Your > proposal however might result in fatal errors from meta-data: > > $reflector = new ReflectionClass(User::class); > $reflector->getAnnotations(); > > // Fatal error: Uncaught Error: Class 'TableName' not found ... > > This is an absolute No-Go for meta-data. > > -- > Richard "Fleshgrinder" Fussenegger >