comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Proposal: Constructors, Assignment [LONG]
Date: Tue, 31 Dec 2002 18:54:50 -0600
Date: 2002-12-31T18:54:50-06:00	[thread overview]
Message-ID: <v14f2p18aetj29@corp.supernews.com> (raw)
In-Reply-To: aumu4o$76buu$1@ID-77047.news.dfncis.de

Dmitry A. Kazakov wrote in message ...
>Randy Brukardt wrote:
>> The basic idea is to somehow figure a value of Ada.Tags.Tag, then use
it
>> to control dispatching on a function that returns the correct kind of
>> object. This requires a special call:
>>
>>       Obj : T'Class := Func (<args>) use Tag_Value;
>
>The question is, will dispatching without an object be useful in cases
other
>than construction?

Yes, I think so. Two other examples have come up:
  -- Calling the parent operation (which Ada does not have any
convinient syntax for - currently you have to name the parent
explicitly, which is a source of bugs);
  -- Handling "least common denominator" comparison.

These aren't wildly compelling, admittedly.

> This proposal requires new syntax. Mine
>
>   Obj : T'Class (<args>);
>
>requires only new attributes.

Adding syntax to a modern compiler is cheap. Either its table driven or
recursive descent; both are quite simple. OTOH, semantics still have to
be implemented by hand. The concern about syntax comes from the cost of
modifying other tools. If there is a way to avoid new syntax without
changing the semantics much, then that is to be preferred. But if we're
talking about implementing simple syntax and semantics compared to
implementing complex semantics only, I'll take a simple syntax change
any day. And your proposal comes under complex semantics, and would be
very expensive to implement in Janus/Ada.

Take your "only attributes" claim. In Janus/Ada (and probably other
compilers), attributes are completely manually implemented. Every
attribute is a bundle of special case code. It's especially expensive
for attributes which can be specified. For instance, stream attributes
(which these resemble) have dedicated components in type records which
hold the current definition. Type records are initialized in a large
variety of places in the compiler, and all of these would need to be
updated (Ada 2005 will help that somewhat, but of course the compiler is
implemented in Ada 95). So your "only new attributes" proposal would
take many times more work to implement. Indeed, it would be impossible
to implement without a wholesale restructuring of the compiler.

Secondly, you are suggesting that somehow:
     Obj : T'Class (<args>);
is somehow the same as
     Obj : T'Class (<discriminants>);

Essentially, you are saying that a discriminant constraint has the same
semantics as a parameter list. But that clearly isn't true in the RM as
written. The rules for these are defined in different places and are
subtly different. Changing them to be the same would be very difficult
without introducing dangerous incompatibilities. While that arguably
might be better for new users, it could be a disaster for existing Ada
users (and code). And it certainly would be a heck of a lot of work.

>Though it is another question, I think that there is a need to have
>something like user-defined anonymous access types, with the operations
>becoming primitive for the pointed type. But it is probably far more
>difficult than just constructors.


Well, there is a proposal for "named anonymous access types" (AI-230).
But the whole idea of a named anonymous type is an oxymoron, and that
turns off a lot of people. And there are quite a few semantic problems
with the proposal. So I wouldn't expect that proposal to be included in
Ada 2005.

                Randy.








  parent reply	other threads:[~2003-01-01  0:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-24 11:16 Proposal: Constructors, Assignment [LONG] Dmitry A. Kazakov
2002-12-26 22:11 ` Nick Roberts
2002-12-27 17:43   ` Dmitry A. Kazakov
2002-12-27 20:17     ` Randy Brukardt
2002-12-29 13:43       ` Dmitry A. Kazakov
2002-12-29 18:45         ` Nick Roberts
2002-12-30 12:23           ` Dmitry A. Kazakov
2002-12-30 15:14             ` Robert A Duff
2002-12-31 13:02               ` Dmitry A. Kazakov
2003-01-01  0:28                 ` Randy Brukardt
2003-01-01 14:13                   ` Dmitry A. Kazakov
2003-01-02 19:44                     ` Randy Brukardt
2003-01-03 13:21                       ` Dmitry A. Kazakov
2003-01-03 19:29                         ` Randy Brukardt
2003-01-03 20:50                       ` Robert A Duff
2003-01-04 12:53                         ` Dmitry A. Kazakov
2003-01-01  0:54         ` Randy Brukardt [this message]
2003-01-01 14:13           ` Dmitry A. Kazakov
2003-01-02 19:36             ` Randy Brukardt
2003-01-03 13:20               ` 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