comp.lang.ada
 help / color / mirror / Atom feed
From: "Mark Lundquist" <up.yerz@nospam.com>
Subject: Re: Protected Object: little question
Date: Sat, 01 Dec 2001 04:00:39 GMT
Date: 2001-12-01T04:00:39+00:00	[thread overview]
Message-ID: <HBYN7.7398$726.3745989@news1.sttln1.wa.home.com> (raw)
In-Reply-To: dstanbro-CBB8ED.08132901122001@mec2.bigpond.net.au


"Dale Stanbrough" <dstanbro@bigpond.net.au> wrote in message
news:dstanbro-CBB8ED.08132901122001@mec2.bigpond.net.au...
> Bruno Hergott wrote:
>
> > If i want to implement an action wich does only read access to the
protected
> > data and wich
> > can
> > be called by 2 tasks at the same time, i must write a function.
> > But i may not need the return value of this function. Because what i
want is
> > not really a
> > function.
> > What i want is "the thing in a protected object to do only read access
to the
> > protected
> > data
> > and wich can be called by 2 tasks at the same time".
[snip]
>
> What do you want it to do with the value you have read? I'm not sure
> why you want to "read" a value, but not do anything with the value
> you have read.

I think he's saying that he has an operation that he wants to read (but not
update) state inside the PO, but it doesn't need to return anything out of
the PO.  Because the operation doesn't update protected state, he doesn't
need the exclusive (writer) access that a protected procedure gets.  He only
needs concurrent (reader) access, i.e. protected against writers but not
other readers -- the kind of access that protected functions have.

Question for the O.P.:

Why can't you write your operation outside the PO, and have a protected
function that just returns the information the operation needs?  That is,
instead of implementing your abstraction *as* a PO, embed a PO in the
implementation of the abstraction.

That said, Ada95's use of function vs. procedure this way does seem a bit
specious, maybe it was a "for lack of a better way" kind of solution.  But I
haven't read the mapping documents etc. so I have to withhold judgement :-)

-- mark








  reply	other threads:[~2001-12-01  4:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-30 19:29 Protected Object: little question Bruno Hergott
2001-11-30 21:15 ` Dale Stanbrough
2001-12-01  4:00   ` Mark Lundquist [this message]
2001-12-01 15:55     ` Nick Roberts
2001-11-30 22:37 ` Jeffrey Carter
2001-12-01 10:43 ` Ehud Lamm
2001-12-03 13:24 ` John English
2001-12-03 15:26   ` Martin Dowie
replies disabled

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