comp.lang.ada
 help / color / mirror / Atom feed
* access-to-constant dispatching params
@ 2000-05-08  0:00 m_cubed
  2000-05-08  0:00 ` Andy
  2000-05-08  0:00 ` Tucker Taft
  0 siblings, 2 replies; 6+ messages in thread
From: m_cubed @ 2000-05-08  0:00 UTC (permalink / raw)


Ada provides access-to-variable dispatching
parameters.

For example:

procedure Set_Exercise_Mode (
  State_Ptr: access State_Type;
  Exercise_Mode: in Exercise_Mode_Type);


What it doesn't seem to provide is
access-to-constant dispatching parameters.
It would be useful to be able to ensure that
a query on an object is prevented from
accidentally updating the object. For example,
(in hypothetical syntax):

function Exercise_Mode (
  State_Ptr: access constant State_Type)
  return Exercise_Mode_Type;


Is there any way of obtaining access-to-constant
dispatching parameters or am I forced to sacrifice
dispatching by using a specific access-to-constant
type:

type RO_Access_State_Type is
  access constant State_Type;

function Exercise_Mode (
  State_Ptr: RO_Access_State_Type)
  return Exercise_Mode_Type;?


Are access-to-constant dispatching parameters
being considered for a future version of Ada?


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: access-to-constant dispatching params
  2000-05-08  0:00 access-to-constant dispatching params m_cubed
@ 2000-05-08  0:00 ` Andy
  2000-05-09  0:00   ` don_harrison
  2000-05-08  0:00 ` Tucker Taft
  1 sibling, 1 reply; 6+ messages in thread
From: Andy @ 2000-05-08  0:00 UTC (permalink / raw)


m_cubed@my-deja.com wrote:
> 
> Ada provides access-to-variable dispatching
> parameters.
> 
> For example:
> 
> procedure Set_Exercise_Mode (
>   State_Ptr: access State_Type;
>   Exercise_Mode: in Exercise_Mode_Type);
> 
> What it doesn't seem to provide is
> access-to-constant dispatching parameters.
> It would be useful to be able to ensure that
> a query on an object is prevented from
> accidentally updating the object. For example,
> (in hypothetical syntax):
> 
> function Exercise_Mode (
>   State_Ptr: access constant State_Type)
>   return Exercise_Mode_Type;
> 

How about using an  in  parameter?

  function Exercise_Mode (
      State : in State_Type)
      return Exercise_Mode_Type;
 

If the code that uses this type are maintaining some sort of structure,
list or array of State_Type pointers, one can always dereference:


   Mode := Exercide_Mode (State =>  State_Ptr.all);

___________________________________________

Andy
___________________________________________




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: access-to-constant dispatching params
  2000-05-08  0:00 access-to-constant dispatching params m_cubed
  2000-05-08  0:00 ` Andy
@ 2000-05-08  0:00 ` Tucker Taft
  2000-05-09  0:00   ` don_harrison
  1 sibling, 1 reply; 6+ messages in thread
From: Tucker Taft @ 2000-05-08  0:00 UTC (permalink / raw)


m_cubed@my-deja.com wrote:
> 
> Ada provides access-to-variable dispatching
> parameters.
> 
> For example:
> 
> procedure Set_Exercise_Mode (
>   State_Ptr: access State_Type;
>   Exercise_Mode: in Exercise_Mode_Type);
> 
> What it doesn't seem to provide is
> access-to-constant dispatching parameters.

This is one thing being considered for Ada 0X.

However, as someone else suggested, plain old "IN" parameters
pretty much do the job and are preferable in certain ways.

> ...
> Are access-to-constant dispatching parameters
> being considered for a future version of Ada?

Yes.
-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Commercial Division, AverStar (formerly Intermetrics)
(http://www.averstar.com/services/IT_consulting.html)  Burlington, MA  USA




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: access-to-constant dispatching params
  2000-05-08  0:00 ` Andy
@ 2000-05-09  0:00   ` don_harrison
  0 siblings, 0 replies; 6+ messages in thread
From: don_harrison @ 2000-05-09  0:00 UTC (permalink / raw)


  andt@nospam.tj wrote:
> m_cubed@my-deja.com wrote:
> >
> > Ada provides access-to-variable dispatching
> > parameters.

[..]

> > What it doesn't seem to provide is
> > access-to-constant dispatching parameters.

[..]

> How about using an  in  parameter?
>
>   function Exercise_Mode (
>       State : in State_Type)
>       return Exercise_Mode_Type;
>
> If the code that uses this type are maintaining some sort of
structure,
> list or array of State_Type pointers, one can always dereference:
>
>    Mode := Exercide_Mode (State =>  State_Ptr.all);

Thanks. That almost gives me what I'm after. (I'll have to wait for
Ada 0X to provide access-to-constant dispatching parameters before I
can acheive consistent signatures using access types).


Don Harrison.


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: access-to-constant dispatching params
  2000-05-08  0:00 ` Tucker Taft
@ 2000-05-09  0:00   ` don_harrison
  2000-05-09  0:00     ` Tucker Taft
  0 siblings, 1 reply; 6+ messages in thread
From: don_harrison @ 2000-05-09  0:00 UTC (permalink / raw)


  Tucker Taft <stt@averstar.com> wrote:
> m_cubed@my-deja.com wrote:
> >
> > Ada provides access-to-variable dispatching
> > parameters.

[..]

> > What it doesn't seem to provide is
> > access-to-constant dispatching parameters.
>
> This is one thing being considered for Ada 0X.
>
> However, as someone else suggested, plain old "IN" parameters
> pretty much do the job and are preferable in certain ways.

In what ways do you consider in-parameters preferable?


Don Harrison


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: access-to-constant dispatching params
  2000-05-09  0:00   ` don_harrison
@ 2000-05-09  0:00     ` Tucker Taft
  0 siblings, 0 replies; 6+ messages in thread
From: Tucker Taft @ 2000-05-09  0:00 UTC (permalink / raw)


don_harrison@my-deja.com wrote:
> 
>   Tucker Taft <stt@averstar.com> wrote:
> > m_cubed@my-deja.com wrote:
> > >
> > > Ada provides access-to-variable dispatching
> > > parameters.
> 
> [..]
> 
> > > What it doesn't seem to provide is
> > > access-to-constant dispatching parameters.
> >
> > This is one thing being considered for Ada 0X.
> >
> > However, as someone else suggested, plain old "IN" parameters
> > pretty much do the job and are preferable in certain ways.
> 
> In what ways do you consider in-parameters preferable?

IN parameters would be preferable to access-to-constant for most
non-dispatching cases, because they are more flexible, allowing
passing of non-aliased objects, the result of calling a function,
an aggregate or a literal, etc.  For dispatching cases, the two
are quite similar, and choosing between them depends on whether
most callers are dealing with access values or objects.
> 
> Don Harrison

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Commercial Division, AverStar (formerly Intermetrics)
(http://www.averstar.com/services/IT_consulting.html)  Burlington, MA  USA




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-05-09  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-08  0:00 access-to-constant dispatching params m_cubed
2000-05-08  0:00 ` Andy
2000-05-09  0:00   ` don_harrison
2000-05-08  0:00 ` Tucker Taft
2000-05-09  0:00   ` don_harrison
2000-05-09  0:00     ` Tucker Taft

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