Re: limited types (Was: Records that could be arrays)



"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.)
.



Relevant Pages

  • Re: Message Builder vs. a Build Method?
    ... Builder class would encapsulate all the complex algorithms for making ... OTOH, as Daniel T. suggests, sometimes the initialization requires unique processing for initialization that is clearly intrinsic to the object itself. ... Constructors tend to be fragile and it is difficult to manage errors when they occur in a constructor scope, so it is usually a good idea to keep the processing in constructors as simple as possible. ... When the initialization of attribute data requires complex processing AND it seems like is intrinsic ot the object, that justifies having a separate initialization method that is invoked immediately after the constructor. ...
    (comp.object)
  • Re: Constructor as a "Reset" Button
    ... constructor is more or less just for initialization, ... In PHP you might get ... And HIPPA certification is not easy - nor is it cheap. ...
    (comp.lang.php)
  • Re: Initialize an array of classes?
    ... Currently you cannot use member initialization list for a nonstatic array of a class if it does not have a default constructor. ... however you may encounter the warning C4351 and I do not think that it is useful to use such initialization for an array. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.languages.vc)
  • Re: C++ design question
    ... >> fooBase has a reference to an object in fooDerived. ... >> fooBase constructor. ... There are several cases where an initialization list is required. ... initialize reference members ...
    (comp.object)
  • Re: what does this mean ?
    ... int main ... To zero-initialize an object of type T means: ... - if T is a non-POD class type, the default constructor for T is ... called (and the initialization is ill-formed if T has no accessible default ...
    (microsoft.public.vc.language)