comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: [announcement] SYSAPI and SYSSVC for Windows
Date: Thu, 25 Dec 2003 15:00:20 +0100
Date: 2003-12-25T15:00:20+01:00	[thread overview]
Message-ID: <bseq5n$bl6kg$1@ID-77047.news.uni-berlin.de> (raw)
In-Reply-To: wcc7k0m2lwy.fsf@shell01.TheWorld.com

Robert A Duff wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> Robert A Duff wrote:
>> 
>> > We should, instead, have allowed the "aliased" keyword on parameters.
>> 
>> No, I think that "aliased" should better be used as a type qualifier:
>> 
>> type X is aliased tagged ...; -- This is a by-reference type
>> type X is tagged ...; -- The compiler is free to choose
>>                       -- (with all the consequences)
> 
> We're not (just) talking about whether parameters are passed by
> reference.  We're (also) talking about whether regular variables are
> aliased.  It seems to me somewhat dangerous, and deserving of a special
> mark on the variable declaration.  (It wasn't allowed at all in Ada 83.)

Yes of course. There should be a choice: either to make all objects aliased
by declaring the whole type aliased (so by-reference), or to allow the
compiler to choose, but also to have an ability to apply "aliased" to an
object or to a subtype:

declare
   subtype Aliased_Integer is aliased Integer;
   X : Aliased_Integer; -- Same as aliased Integer

To have "aliased" in the parameter profile, would mean an anonymous aliased
subtype. This is OK, but then we should probably to make the consequent
steps allowing anonymous subtypes of all sorts:

procedure Get_Line (Line : in out String (1..Get_Line_Width));

That could be poblematic.

>> For parameters there are access types. IMO it is a bad idea to get
>> pointers to parameters, if that is really needed one should pass a
>> pointer instead.
> 
> I think I agree with that, but then you trip over another design mistake
> -- there's no such thing as an "access constant" parameter.

Yes.

>> A good example is Finalize. There is a nasty problem to get a pointer to
>> the parameter of Finalize, because there is no way to figure out which
>> pool it should be. For by-reference types it should be sort of:
>> 
>> procedure Finalize (Object : access not all Object_Type); -- (:-))
> 
> I'm not sure what you mean.  How does this tell you what pool Object is
> in (maybe none!)?

That was a joke! Though seriosly, there should be some way to work with pool
objects. Presently, pool is decoupled from the object type. It makes sense,
but quite often one wishes to allocate controlled objects in a specific
pool. Maybe we should allow:

type Object_Type is
   new Ada.Finalization.Limited_Pool_Specific with private;
for Object_Type'Storage use Pool;
type Ptr is access Object_Type;
   -- Implies for Ptr'Storage_Pool use Pool;

A : Object_Type; -- Compile error

procedure Foo (A : access Object_Type); -- A is specific to Pool
procedure Finalize (Object : access Object_Type);

With MD we could make Finalize dispatching on both Object and Pool:

procedure Finalize
(  Object : access Object_Type; -- Object is specific to Pool
   Pool   : in out Root_Storage_Pool
);

But this would require too much work.

>> Then I would disallow overloading like this:
>> 
>> procedure Foo (Object : access Object_Type);
>> procedure Foo (Object : in out Object_Type);
>> 
>> Instead of this I would make access types transparent to primitive
>> operations, as they are to array indexing and record member extraction.
> 
> We proposed something like that (implicit .all) in the early stages of
> the Ada 9X project.
> 
> I actually don't like implicit dereference at all, even for selected
> components.  But the problem is that .all is so verbose and ugly, it
> *needs* to be implicit.  If it were up to me, the syntax for dereference
> would be Pointer^ (from Pascal), which is unobtrusive, but still makes
> the dereference explicit.  Following a pointer and selecting a record
> component is semantically much different from just selecting a record
> component -- the syntax should convey that.

I see it completely different. To me an access type should be just a subtype
of the target type, so it would inherit all operations of the "base". To do
it I would allow user-defined subtypes privately implemented in this case
by a hard-wired access type:

   type Object is ...;
   subtype Handle is private Object;
private
   type Handle is access Object;

This would mean that all operations would be transparent, what one indeed
expects from a handle. With appopriate constructors and destructors it
could be made dangling-pointer safe. It would probably make 'Access
attribute and anonymous access types superfluos in most cases. Though there
would definitely be a problem with recursive types to solve.

-- 
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de



  reply	other threads:[~2003-12-25 14:00 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-17 19:17 [announcement] SYSAPI and SYSSVC for Windows amado.alves
2003-12-17 19:56 ` Georg Bauhaus
2003-12-18  9:08 ` Dmitry A. Kazakov
2003-12-18 12:14   ` Ekkehard Morgenstern
2003-12-18 13:31     ` Georg Bauhaus
2003-12-19 10:45       ` Ekkehard Morgenstern
2003-12-19 17:12         ` Georg Bauhaus
2003-12-19 17:22           ` Vinzent 'Gadget' Hoefler
2003-12-20  0:21           ` Ekkehard Morgenstern
2003-12-20  2:18             ` Georg Bauhaus
2003-12-20  4:40               ` Ekkehard Morgenstern
2003-12-21  3:45                 ` Georg Bauhaus
2003-12-21 19:01                   ` Piracy was " Robert I. Eachus
2003-12-18 14:32     ` Dmitry A. Kazakov
2003-12-19 11:11       ` Ekkehard Morgenstern
2003-12-19 15:15         ` Hyman Rosen
2003-12-19 15:50           ` Ekkehard Morgenstern
2003-12-19 16:48             ` Hyman Rosen
2003-12-19 16:57               ` Hyman Rosen
2003-12-20  1:17               ` Ekkehard Morgenstern
2003-12-21  2:19                 ` Hyman Rosen
2003-12-21 10:34                   ` Ekkehard Morgenstern
2003-12-22  9:02                     ` Hyman Rosen
2003-12-22 15:17                       ` Ekkehard Morgenstern
2003-12-22 15:08                     ` Hyman Rosen
2003-12-22 15:31                       ` Ekkehard Morgenstern
2003-12-22 16:35                         ` Ekkehard Morgenstern
2003-12-23  1:47                           ` Hyman Rosen
2003-12-23  8:40                             ` Ekkehard Morgenstern
2003-12-23  9:05                               ` Stephen Leake
2003-12-19 17:06         ` Dmitry A. Kazakov
2003-12-20  1:49           ` Ekkehard Morgenstern
2003-12-20 11:13             ` Dmitry A. Kazakov
2003-12-20 13:40               ` Ekkehard Morgenstern
2003-12-20 17:21                 ` Dmitry A. Kazakov
2003-12-20 19:52                   ` Ekkehard Morgenstern
2003-12-21  4:24                     ` Georg Bauhaus
2003-12-21 13:42                     ` Dmitry A. Kazakov
2003-12-21 15:48                       ` Ekkehard Morgenstern
2003-12-21 17:46                         ` Michal Morawski
2003-12-21 18:05                           ` Ekkehard Morgenstern
2003-12-22  0:50                             ` Robert I. Eachus
2003-12-23 23:02                       ` Robert A Duff
2003-12-24 11:20                         ` Dmitry A. Kazakov
2003-12-24 16:57                           ` Robert A Duff
2003-12-25 14:00                             ` Dmitry A. Kazakov [this message]
2003-12-28  1:49                       ` Dave Thompson
  -- strict thread matches above, loose matches on Subject: below --
2003-12-15 14:18 Ekkehard Morgenstern
2003-12-15 15:10 ` Ekkehard Morgenstern
2003-12-15 17:10 ` Jeffrey Carter
2003-12-15 18:38   ` Ekkehard Morgenstern
2003-12-16  0:25     ` Stephen Leake
2003-12-16  0:56       ` Ekkehard Morgenstern
2003-12-16  2:47         ` Ludovic Brenta
2003-12-16 17:45           ` Ekkehard Morgenstern
2003-12-16 19:54             ` Ludovic Brenta
2003-12-16 22:09               ` Ekkehard Morgenstern
2003-12-17 15:24                 ` Ludovic Brenta
2003-12-17 23:23                   ` Ekkehard Morgenstern
2003-12-19 18:14                   ` Warren W. Gay VE3WWG
2003-12-16  5:36         ` tmoran
2003-12-16 17:30           ` Ekkehard Morgenstern
2003-12-15 20:44 ` David Marceau
2003-12-16  0:34   ` Ekkehard Morgenstern
2003-12-17 12:05 ` Dmitry A. Kazakov
2003-12-17 15:00   ` Ekkehard Morgenstern
2003-12-20 19:24 ` Ekkehard Morgenstern
replies disabled

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