comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Drummond <brian@shapes.demon.co.uk>
Subject: Re: Question about name resolution
Date: Wed, 21 Jan 2015 10:54:39 +0000 (UTC)
Date: 2015-01-21T10:54:39+00:00	[thread overview]
Message-ID: <m9o0hf$aeb$1@dont-email.me> (raw)
In-Reply-To: m9mstq$hja$1@dont-email.me

On Tue, 20 Jan 2015 17:47:20 -0700, Jeffrey Carter wrote:

> On 01/20/2015 12:32 PM, Michael B. wrote:
>> 
>> I was surprised that this compiles without warnings if neither of the
>> procedures is called. Why is such overloading allowed in Ada? It seems
>> to make no sense to write a procedure that cannot be called directly.

> In Ada 83 and later, the call
> 
>    F (5)
> 
> is ambiguous. It could either be
> 
> F1 with an argument of 5
> 
> or
> 
> F2 with the result indexed by 5
> 
> In Ada 80 this was unambiguous; the call could only be to F1. To call F2
> one had to write
> 
> F () (5)
> 
> This is not very helpful but I always like an excuse to air the useless
> trivia in my head.

Similar ambiguity was inherited by VHDL. Some big-name simulators still 
get it wrong, arbitrarily resolving the ambiguity as F1 with argument, 
some failing to compile legal VHDL where the ambiguity could be resolved 
by the return type. 

For example where F returns a string of specified (or default) length:

function F(Len : Natural := 5) return String;

variable c: character := F(5); 
is legal, unambiguous, yet rejected by some embarrassingly expensive 
tools, where

variable s : string := "hello " & F(5);
is ambiguous (because "&") overloads) but arbitrarily resolved as 
concatenating two strings.

-- Brian

-- Brian

  reply	other threads:[~2015-01-21 10:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-20 18:47 Question about name resolution Michael B.
2015-01-20 19:00 ` Jeffrey Carter
2015-01-20 19:32   ` Michael B.
2015-01-20 20:39     ` Robert A Duff
2015-01-21 18:25       ` Michael B.
2015-01-21  0:47     ` Jeffrey Carter
2015-01-21 10:54       ` Brian Drummond [this message]
2015-01-20 19:43 ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox