From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: attributes on expressions, not name Date: Wed, 28 Feb 2018 19:55:47 +0200 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net Pc5itiSVUFBiwK12qSdjJgSDsr5kG0VEDmpist0tzbH6mt/DQZ Cancel-Lock: sha1:4k6TNHuGZe5B66c/+wLA2C7I3Kc= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: reader02.eternal-september.org comp.lang.ada:50717 Date: 2018-02-28T19:55:47+02:00 List-Id: On 18-02-28 18:57 , Mehdi Saada wrote: > why aren't attributes allowed on expressions ? > Like LINE'Length, assuming LINE is a function returning STRING. There is no such limitation. RM 4.1.4: attribute_reference ::= prefix'attribute_designator RM 4.1: prefix ::= name ... RM 4.1; name ::= ... function_call ... > The type of an expression is always static, The type of the value returned by a function call is known only after compile-time overload resolution, which depends on the context of the expression. Applying an attribute to (the result of) a function call does not always provide enough context to resolve overloading. In your example, there could be several different functions called LINE, some returning types to which the Length attribute could apply, and some returning types to which it does not apply. It is not clear which of these functions should be called. If I have one function LINE return String, and another LINE return Integer, and try to compute LINE'Length, GNAT tells me: func_attr.adb:22:41: ambiguous prefix for "Length" attribute Is that the error message you get? -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .