Re: limited types (Was: Records that could be arrays)
- From: Matthew Heaney <matthewjheaney@xxxxxxxxxxxxx>
- Date: Sat, 25 Feb 2006 15:05:02 GMT
"Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx> writes:
I think that there should also be [limited] containers of limited types.
For this we need a construction model, which would allow user-defined
in-place constructors. After all Ada has always had arrays of limited
components. We have to extend this model onto user-defined containers.
But you can pass in an Initialize procedure as a parameter of an insertion
operation, to perform whatever initialization needs to be done.
Also (see below for ex), you already have copy ctors for Ada 2005, even for
limited types.
I think that this would require separation of assignment from copy
constructor, as C++ does. Though the default must be that assignment is
generated from destructor and copy constructor.
You could pass in a copy constructor if this were an unbounded form (I thik),
something like:
procedure Insert
(C : in out CT;
E : in ET;
Copy : not null access function (E : ET) return ET)
is
Node : Node_Access :=
new Node_Type'(Element => Copy (E), others => <>);
begin
...
end;
Wouldn't that work? I don't have a compiler that can do that yet, but I know
this would be legal:
procedure Op (E : ET) is
EE : ET := Copy (E);
begin
...
end;
so I assume initialization of an aggregate is the same. (But I could be
wrong.)
.
- Follow-Ups:
- Re: limited types (Was: Records that could be arrays)
- From: Dmitry A. Kazakov
- Re: limited types (Was: Records that could be arrays)
- From: Randy Brukardt
- Re: limited types (Was: Records that could be arrays)
- References:
- limited types (Was: Records that could be arrays)
- From: Thierry Bernier
- Re: limited types (Was: Records that could be arrays)
- From: Randy Brukardt
- Re: limited types (Was: Records that could be arrays)
- From: Dmitry A. Kazakov
- limited types (Was: Records that could be arrays)
- Prev by Date: OT: Re: help with include and library files in GPS
- Next by Date: Re: GNAT GPL compile problems
- Previous by thread: Re: limited types (Was: Records that could be arrays)
- Next by thread: Re: limited types (Was: Records that could be arrays)
- Index(es):
Relevant Pages
|
|