From: mheaney@on2.com (Matthew Heaney)
Subject: Re: "access constant" discriminant
Date: 24 Feb 2003 11:11:57 -0800
Date: 2003-02-24T19:11:57+00:00 [thread overview]
Message-ID: <1ec946d1.0302241111.3e816bb@posting.google.com> (raw)
In-Reply-To: v5d1sfo9ib2df9@corp.supernews.com
"Randy Brukardt" <randy@rrsoftware.com> wrote in message news:<v5d1sfo9ib2df9@corp.supernews.com>...
> Matthew Heaney wrote in message
> <1ec946d1.0302201642.66eb93e5@posting.google.com>...
>
> >Here we see the reason why we passed an access parameter: it's because
> >we're returning an access value that designates one of our own
> >components.
>
>
> That reason being only that Ada doesn't support 'in out' parameters on
> functions. If it did,
>
> fuction Persistence_View
> (Object : in out T) return Persistence_Class_Access is
> begin
> return Object.Persistence_View'Access;
> end;
>
> would work fine, and would be a lot easier to use as well.
No -- this would be the wrong way to implement the multiple views
idiom. You really do want to make explicit the fact that the object
is being aliased.
For example, in C++ I could do this:
X x;
Y y(x);
and implement Y this way:
class Y
{
X& x;
public:
Y(X& xx) : x(xx) {}
//...
private:
Y(const Y&);
Y& operator=(const Y&);
};
but that would be entirely misleading, even if it's "easier" to
declare a Y object. It's better to implement Y's ctor using an
explicit pointer:
class Y
{
X& x;
public:
Y(X* px) : x(*px) {}
private:
Y(const Y&);
Y& operator=(const Y&);
};
and then say:
X x;
Y y(&x);
Which makes it identical to how you'd say it in Ada95. So this is not
really an Ada issue.
> But that's not going to happen, so we're stuck with terrible workarounds
> like 'access' parameters.
Access parameters have other uses besides getting around the lack of
inout mode for function parameters. For example, operations that
accept a user-defined type as an access parameter are primitive for
the type, and hence are inherited in a derivation. And an access
parameter means you don't have to say Op (O.all) everywhere.
However, we are in agreement that not having inout mode for functions
is a ridiculous restriction, since functions in Ada95 do modify their
arguments (the language just doesn't let you *say* that you do).
next prev parent reply other threads:[~2003-02-24 19:11 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-10 8:26 "access constant" discriminant tmoran
2003-02-10 14:43 ` Frank J. Lhota
2003-02-10 18:57 ` tmoran
2003-02-15 19:17 ` Richard Riehle
2003-02-15 19:59 ` Larry Kilgallen
2003-02-15 23:53 ` Richard Riehle
2003-02-16 1:50 ` Eric G. Miller
2003-02-20 2:23 ` Matthew Heaney
2003-02-20 17:34 ` Stephen Leake
2003-02-21 0:42 ` Matthew Heaney
2003-02-21 10:41 ` Lutz Donnerhacke
2003-02-21 20:21 ` Randy Brukardt
2003-02-23 12:22 ` Simon Wright
2003-02-24 7:06 ` Dale Stanbrough
2003-02-24 18:58 ` Matthew Heaney
2003-02-24 21:05 ` Randy Brukardt
2003-02-25 14:15 ` Frank J. Lhota
2003-02-26 1:05 ` Randy Brukardt
2003-02-24 16:03 ` Matthew Heaney
2003-02-21 15:03 ` Hyman Rosen
2003-02-21 20:09 ` Randy Brukardt
2003-02-21 21:33 ` Matthew Heaney
2003-02-21 20:07 ` Randy Brukardt
2003-02-24 19:11 ` Matthew Heaney [this message]
2003-02-24 21:17 ` Randy Brukardt
2003-02-25 17:49 ` Richard Riehle
2003-02-20 2:23 ` Matthew Heaney
2003-02-20 2:20 ` Matthew Heaney
2003-02-10 19:26 ` Robert A Duff
2003-02-10 22:27 ` Rod Chapman
2003-02-11 2:00 ` Jeffrey Carter
2003-02-20 2:28 ` Matthew Heaney
2003-02-20 9:45 ` Lutz Donnerhacke
2003-02-20 2:17 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox