comp.lang.ada
 help / color / mirror / Atom feed
* Ada.Containers.Indefinite_Holders in GNAT and Ada2012
@ 2014-08-09 19:25 Victor Porton
  2014-08-09 19:43 ` Victor Porton
  2014-08-09 21:54 ` Simon Wright
  0 siblings, 2 replies; 8+ messages in thread
From: Victor Porton @ 2014-08-09 19:25 UTC (permalink / raw)


I tried to write:

Element(Object)'Access;

for "Object" being a value of an instance of 
Ada.Containers.Indefinite_Holders.

This does not work because the return type of Element is not aliased.

Then I tried:

Reference(Object).all'Access;

This does not work because in GNAT 4.9 a-coinho.ads source file is not up to 
date with Ada2012 and there are no Reference function here.

My questions:

1. How long to wait for GNAT to work with this? (in which GNAT version?)

2. In a conforming Ada2012 compiler `Reference(Object).all'Access;` is 
semantically correct, isn't it?

In the meantime, I need to write for my private use a container similar to 
Ada.Containers.Indefinite_Holders for aliased objects by myself :-(

-- 
Victor Porton - http://portonvictor.org

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

* Re: Ada.Containers.Indefinite_Holders in GNAT and Ada2012
  2014-08-09 19:25 Ada.Containers.Indefinite_Holders in GNAT and Ada2012 Victor Porton
@ 2014-08-09 19:43 ` Victor Porton
  2014-08-10 13:06   ` Victor Porton
  2014-08-11 23:58   ` Randy Brukardt
  2014-08-09 21:54 ` Simon Wright
  1 sibling, 2 replies; 8+ messages in thread
From: Victor Porton @ 2014-08-09 19:43 UTC (permalink / raw)


Victor Porton wrote:

> I tried to write:
> 
> Element(Object)'Access;
> 
> for "Object" being a value of an instance of
> Ada.Containers.Indefinite_Holders.
> 
> This does not work because the return type of Element is not aliased.

By the way, does it makes sense in the next Ada specification to make the 
return type of "Element" function aliased?

> Then I tried:
> 
> Reference(Object).all'Access;
> 
> This does not work because in GNAT 4.9 a-coinho.ads source file is not up
> to date with Ada2012 and there are no Reference function here.
> 
> My questions:
> 
> 1. How long to wait for GNAT to work with this? (in which GNAT version?)
> 
> 2. In a conforming Ada2012 compiler `Reference(Object).all'Access;` is
> semantically correct, isn't it?
> 
> In the meantime, I need to write for my private use a container similar to
> Ada.Containers.Indefinite_Holders for aliased objects by myself :-(
> 
-- 
Victor Porton - http://portonvictor.org


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

* Re: Ada.Containers.Indefinite_Holders in GNAT and Ada2012
  2014-08-09 19:25 Ada.Containers.Indefinite_Holders in GNAT and Ada2012 Victor Porton
  2014-08-09 19:43 ` Victor Porton
@ 2014-08-09 21:54 ` Simon Wright
  1 sibling, 0 replies; 8+ messages in thread
From: Simon Wright @ 2014-08-09 21:54 UTC (permalink / raw)


Victor Porton <porton@narod.ru> writes:

> This does not work because in GNAT 4.9 a-coinho.ads source file is not up to 
> date with Ada2012 and there are no Reference function here.
>
> My questions:
>
> 1. How long to wait for GNAT to work with this? (in which GNAT version?)

Very likely will be fixed in FSF GCC 4.10, because Reference is present
in GNST GPL 2014.

> In the meantime, I need to write for my private use a container
> similar to Ada.Containers.Indefinite_Holders for aliased objects by
> myself :-(

If it's only for private use you could use the GPL compiler.

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

* Re: Ada.Containers.Indefinite_Holders in GNAT and Ada2012
  2014-08-09 19:43 ` Victor Porton
@ 2014-08-10 13:06   ` Victor Porton
  2014-08-10 15:32     ` Simon Wright
                       ` (2 more replies)
  2014-08-11 23:58   ` Randy Brukardt
  1 sibling, 3 replies; 8+ messages in thread
From: Victor Porton @ 2014-08-10 13:06 UTC (permalink / raw)


Victor Porton wrote:

> Victor Porton wrote:
> 
>> I tried to write:
>> 
>> Element(Object)'Access;
>> 
>> for "Object" being a value of an instance of
>> Ada.Containers.Indefinite_Holders.
>> 
>> This does not work because the return type of Element is not aliased.
> 
> By the way, does it makes sense in the next Ada specification to make the
> return type of "Element" function aliased?

Hm, my idea was wrong: Element may return a copy instead of the actual 
element.

However I propose to add Element_Access to next RM which would return access 
to the element in the container.

One (real World!) usage for this: Interfaces.C.Strings.To_Chars_Ptr applied 
to an element in an indefinite holder of type char_array.

>> Then I tried:
>> 
>> Reference(Object).all'Access;
>> 
>> This does not work because in GNAT 4.9 a-coinho.ads source file is not up
>> to date with Ada2012 and there are no Reference function here.
>> 
>> My questions:
>> 
>> 1. How long to wait for GNAT to work with this? (in which GNAT version?)
>> 
>> 2. In a conforming Ada2012 compiler `Reference(Object).all'Access;` is
>> semantically correct, isn't it?
>> 
>> In the meantime, I need to write for my private use a container similar
>> to Ada.Containers.Indefinite_Holders for aliased objects by myself :-(

-- 
Victor Porton - http://portonvictor.org

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

* Re: Ada.Containers.Indefinite_Holders in GNAT and Ada2012
  2014-08-10 13:06   ` Victor Porton
@ 2014-08-10 15:32     ` Simon Wright
  2014-08-11 11:01     ` AdaMagica
  2014-08-11 15:38     ` Adam Beneschan
  2 siblings, 0 replies; 8+ messages in thread
From: Simon Wright @ 2014-08-10 15:32 UTC (permalink / raw)


Victor Porton <porton@narod.ru> writes:

> One (real World!) usage for this: Interfaces.C.Strings.To_Chars_Ptr
> applied to an element in an indefinite holder of type char_array.

I don't know what your actual usage is, but I'd prefer in general to
keep to Ada types in the application, and only do interfacing at the
edges.

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

* Re: Ada.Containers.Indefinite_Holders in GNAT and Ada2012
  2014-08-10 13:06   ` Victor Porton
  2014-08-10 15:32     ` Simon Wright
@ 2014-08-11 11:01     ` AdaMagica
  2014-08-11 15:38     ` Adam Beneschan
  2 siblings, 0 replies; 8+ messages in thread
From: AdaMagica @ 2014-08-11 11:01 UTC (permalink / raw)


> However I propose to add Element_Access to next RM which would return access 
> to the element in the container.

I doubt this will happen because the access you propose may outlive the object is accesses. This is why there are reference objects.

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

* Re: Ada.Containers.Indefinite_Holders in GNAT and Ada2012
  2014-08-10 13:06   ` Victor Porton
  2014-08-10 15:32     ` Simon Wright
  2014-08-11 11:01     ` AdaMagica
@ 2014-08-11 15:38     ` Adam Beneschan
  2 siblings, 0 replies; 8+ messages in thread
From: Adam Beneschan @ 2014-08-11 15:38 UTC (permalink / raw)


On Sunday, August 10, 2014 6:06:21 AM UTC-7, Victor Porton wrote:

> However I propose to add Element_Access to next RM which would return access 
> to the element in the container.

Since the RM already has Reference, and a Reference type has an Element component whose type is an access type, what would be gained by an Element_Access?

                               -- Adam

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

* Re: Ada.Containers.Indefinite_Holders in GNAT and Ada2012
  2014-08-09 19:43 ` Victor Porton
  2014-08-10 13:06   ` Victor Porton
@ 2014-08-11 23:58   ` Randy Brukardt
  1 sibling, 0 replies; 8+ messages in thread
From: Randy Brukardt @ 2014-08-11 23:58 UTC (permalink / raw)


"Victor Porton" <porton@narod.ru> wrote in message 
news:ls5tkt$6g2$1@speranza.aioe.org...
> Victor Porton wrote:
>
>> I tried to write:
>>
>> Element(Object)'Access;
>>
>> for "Object" being a value of an instance of
>> Ada.Containers.Indefinite_Holders.
>>
>> This does not work because the return type of Element is not aliased.
>
> By the way, does it makes sense in the next Ada specification to make the
> return type of "Element" function aliased?

Ada doesn't allow return objects to be declared "aliased". We looked at 
allowing that when we added "aliased" parameters, but the semantics would 
have been unusual at best. We couldn't figure out what it mean in various 
usual cases (as you note later, Ada usually allows the return to be a copy, 
and this is important for some kinds of types).

Since it's doesn't make sense (in general) for a return object to be 
aliased, it couldn't make sense to allow that in a generic.

                                                  Randy.




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

end of thread, other threads:[~2014-08-11 23:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-09 19:25 Ada.Containers.Indefinite_Holders in GNAT and Ada2012 Victor Porton
2014-08-09 19:43 ` Victor Porton
2014-08-10 13:06   ` Victor Porton
2014-08-10 15:32     ` Simon Wright
2014-08-11 11:01     ` AdaMagica
2014-08-11 15:38     ` Adam Beneschan
2014-08-11 23:58   ` Randy Brukardt
2014-08-09 21:54 ` Simon Wright

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