From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Min/Max attribute makes promises it can't keep
Date: Sat, 1 May 2010 08:28:10 +0200
Date: 2010-05-01T08:28:11+02:00 [thread overview]
Message-ID: <rypl0nzasa10$.1drivrnhe5u64$.dlg@40tude.net> (raw)
In-Reply-To: hrgf10$qvv$1@munin.nbi.dk
On Sat, 1 May 2010 00:42:53 -0500, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:1p28brlj9yc3k$.1nv0ey1aadvoi$.dlg@40tude.net...
>> On Wed, 28 Apr 2010 16:07:24 -0500, Randy Brukardt wrote:
>>
>>> As for the initial concern about giving a subtype name, in the case of
>>> literals you have to give one somewhere (since a literal can be of many
>>> different types, and the results can vary depending on the type used --
>>> not
>>> for 'Length, but for 'Last and most other properties).
>>
>> No problem, Ada supports overloading in the result type. E.g. abs (-1) is
>> OK.
>
> That doesn't help. Consider:
>
> type My_String is array (Natural range <>) of Character;
>
> Now, if you wrote:
>
> "ABC"'First
>
> The answer depends on whether the type of the prefix is String or My_String,
> but the type is Integer'Base in both cases. No amount of overloading will
> help.
How is that different to:
package P is
function ABC return String;
end P;
package Q is
type My_String is array (Natural range <>) of Character;
function ABC return My_String;
end Q;
use P,Q;
...
ABC'First; -- Ambiguous
> The language does not want the compiler to have to list out all of the
> possible types for a string literal, figure out the appropriate bounds for
> all of them, take all of the ones with the appropriate index type, and then
> allow the attribute if the answer is the same.
That would be silly, of course. But it is not what I meant. Attribute
should be an overloaded operation as any other. If the expression happens
to be ambiguous there are language means to specify what it is.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2010-05-01 6:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-27 19:34 Min/Max attribute makes promises it can't keep Alex Mentis
2010-04-27 20:20 ` Martin
2010-04-27 21:16 ` Robert A Duff
2010-04-27 22:46 ` Randy Brukardt
2010-04-28 10:36 ` Alex Mentis
2010-04-28 10:58 ` AdaMagica
2010-04-28 11:37 ` Gautier write-only
2010-04-28 11:47 ` AdaMagica
2010-04-28 13:28 ` Martin
2010-04-28 13:41 ` Dmitry A. Kazakov
2010-04-28 14:10 ` Georg Bauhaus
2010-04-28 14:53 ` Dmitry A. Kazakov
2010-04-28 21:07 ` Randy Brukardt
2010-04-28 22:17 ` Dmitry A. Kazakov
2010-05-01 5:42 ` Randy Brukardt
2010-05-01 6:28 ` Dmitry A. Kazakov [this message]
2010-04-29 4:41 ` AdaMagica
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox