From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Overloading operator "=" for anonymous access types?
Date: Wed, 16 Jan 2019 16:42:04 +0100
Date: 2019-01-16T16:42:04+01:00 [thread overview]
Message-ID: <q1njcb$1c43$1@gioia.aioe.org> (raw)
In-Reply-To: q1lhlg$38b$1@franka.jacob-sparre.dk
On 2019-01-15 22:00, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:q1k65j$1qqm$1@gioia.aioe.org...
> ...
>> [ The reference manual is shy to say anything about it. It claims that
>> universal_access is kind of class-wide, which would mean, if taken
>> seriously, that "=" overloads and must clash with the original "=".
>
> This is what happens. However, such a clash would mean that you could never
> write a user-defined "=" for an anonymous access type. That would have been
> a good idea, but it would have to have been enforced with a Legality Rule to
> be sensible. Some thought that bad because of compatibility, so...
>
>> Since it does not, universal_access is more like a parent type than
>> class-wide.]
>
> ...there is a hack to have a preference for the user-defined one. That
> doesn't change the the fact that universal_access is class-wide, it just
> make it possible to write a user-defined operator.
Yes, you need hacks to handle inconsistencies and weaknesses.
>> P.S. And, wouldn't it be better to fix the type system, no?
>
> This wart would be one of the things that would make "fixing the type
> system" so much harder. A proper solution (and the one we should have used
> in the first place) is to declare a "=" for every access type. I think we
> wanted to avoid that as anonymous access can be declared in places where
> declarations aren't allowed, so we came up with something worse. :-)
I think the problem is that all operations with access T as an argument
should be primitive operations of T. That was the idea behind anonymous
access types all the time. But some types are not so much types to have
classes.
> It's the idea of anonymous access types that destroys the type system that
> you have in mind. Your system keeps the types and operations together, and
> that makes no sense for an anonymous type (what are the operations for an
> anonymous type, and where are they declared? Any answer is either magical or
> nonsense.)
Yes, there is a conflict between anonymous access type treated as a
standalone type and as a parameter passing mode of the target type.
> One has to get rid of nonsense things before one could regularize the type
> system, especially upon the lines you have been suggesting for years. It's
> not really possible for Ada; you would end up with an Ada-like language.
We may be able to express this in the terms of a more general type
system. If anonymous access would be a mere user-defined type with all
its perks that would be OK.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2019-01-16 15:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-11 21:46 Overloading operator “=” for anonymous access types? daicrkk
2019-01-12 9:50 ` Simon Wright
2019-01-12 14:01 ` Simon Wright
2019-01-12 15:15 ` daicrkk
2019-01-14 23:08 ` Overloading operator "=" " Randy Brukardt
2019-01-15 0:34 ` Shark8
2019-01-15 8:38 ` Dmitry A. Kazakov
2019-01-15 21:00 ` Randy Brukardt
2019-01-16 15:42 ` Dmitry A. Kazakov [this message]
2019-01-15 8:51 ` daicrkk
2019-01-15 11:15 ` Simon Wright
2019-01-17 3:20 ` Jere
2019-01-17 8:23 ` Dmitry A. Kazakov
2019-01-17 22:22 ` Randy Brukardt
2019-01-18 10:17 ` Dmitry A. Kazakov
2019-01-18 13:27 ` Jere
2019-01-18 13:42 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox