Re: Containers - nontrivial element access
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Wed, 3 Oct 2007 21:35:57 +0200
On Wed, 03 Oct 2007 18:49:58 GMT, Jeffrey R. Carter wrote:
Dmitry A. Kazakov wrote:
This is IMO utterly wrong. The semantics of swapping element's fields is
well-defined independently on the way of access. In question in not the
semantics of, but the syntax sugar, namely an array-like indexing of the
container.
Swapping was only an example. Essentially, the OP was looking for the
ability to do
People.Element (X).Salary := S;
and have it modify the value in the data structure.
Which is no problem if Element is an array field of records having the
field Salary. Ada does not prescribe whether that would be by reference.
AFAIK, the compiler is allowed to rewrite the whole People if it wanted to.
The compiler is free to choose between the decompositions:
":=" (People.Element (X).Salary, 3)
":=" (People.Element (X), ".Salary", 3)
":=" (People, "Element", X, "Salary", 3)
This freedom is not offered to the developer of a component library.
C++ uses reference semantics, so that a modification of a field modifies
the value in the data structure. Ada uses value semantics, so that
modification of a field does not modify the value in the data structure.
? For by-value things Ada compiler just does copy-out / copy-in,
transparently.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- References:
- Containers - nontrivial element access
- From: Maciej Sobczak
- Re: Containers - nontrivial element access
- From: Jeffrey R. Carter
- Re: Containers - nontrivial element access
- From: Maciej Sobczak
- Re: Containers - nontrivial element access
- From: Jeffrey R. Carter
- Re: Containers - nontrivial element access
- From: Dmitry A. Kazakov
- Re: Containers - nontrivial element access
- From: Jeffrey R. Carter
- Containers - nontrivial element access
- Prev by Date: Re: GNAT for MS Visual Studio
- Next by Date: Re: Containers - nontrivial element access
- Previous by thread: Re: Containers - nontrivial element access
- Next by thread: Re: Containers - nontrivial element access
- Index(es):
Relevant Pages
|